<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div>123</div>
<script>
var div=document.querySelector('div');
div.onclick=function (event) {
//event是事件对象
//事件对象只有有了事件才存在
//事件对象是一些列与事件相关的数据的集合
console.log(event);
console.log(event.target)//返回触发事件对象
console.log(this);//返回绑定事件对象
}
//开发中通常用e
div.addEventListener('click',function (event) {
console.log(event);
})
//e.targer点击了那个元素就返回那个元素,this那个元素绑定了事件就返回谁
</script>
</body>
</html>