1 Star 0 Fork 0

白龙马 / HTML-CSS-JS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
14JS事件.html 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
白龙马 提交于 2024-02-23 08:28 . 第一次上传gitee十四
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>14 JavaScript 事件</title>
</head>
<body>
<h1>14 JavaScript 事件</h1>
JavaScript 绑定事件的方法有三种:
<h2>1 HTML 属性</h2>
<button onclick="click_event()">此按钮绑定了点击事件onClick按钮</button>
<br><br>
<input type="text" onfocus="focus_event()" onblur="blur_event()"
placeholder="此文本输入框绑定了onfocus和onblur事件"
style="width: 250px;">
<h2>2 DOM 属性</h2>
<h2>3 addEventListener 方法</h2>
</body>
</html>
<script>
// 点击事件
function click_event() {
alert('点击事件onClick触发了');
}
// 聚焦事件
function focus_event() {
console.log('获得焦点事件onFocus触发了');
}
// 失焦事件
function blur_event() {
console.log('失去焦点事件onBlur触发了');
}
</script>
HTML
1
https://gitee.com/blma/html-css-js.git
git@gitee.com:blma/html-css-js.git
blma
html-css-js
HTML-CSS-JS
master

搜索帮助