<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!--
事件,就是用户与浏览器之间的交互
如:单击、双击、鼠标移动、关闭窗口...
在事件对应的属性中设计js代码,触发事件就调用js代码
-->
<button onclick="alert('点击我了')">我是一个按钮</button>
<!--上面的时间写法过于耦合,不推荐-->
<button id="in">我是js一个按钮</button>
<script type="text/javascript">
//.绑定js函数来处理事件
//获取对象
var btn=document.getElementById("in");
//处理事件
btn.onclick=function (){
alert("又点击我了");
}
//.各种事件
// https://www.w3cschool.cn/jsref/dom-obj-event.html
</script>
</body>
</html>