<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 300px;
height: 300px;
background-color: #f0f;
}
.son {
width: 100px;
height: 100px;
background-color: #0ff;
}
</style>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
<script>
document.addEventListener('click', function () {
console.log(1);
}, true)
document.querySelector('.father').addEventListener('click', function () {
console.log(2);
}, true)
document.querySelector('.son').addEventListener('click', function () {
console.log(3);
}, true)
</script>
</body>
</html>
事件流的顺序
最新推荐文章于 2023-04-12 14:31:51 发布