2018-08-13 冒泡事件的验证
程序员文章站
2022-06-16 09:17:36
...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>点击事件捕获冒泡</title>
</head>
<body>
<div id="grandPa">
<div id="father">
<div id="son">
<input type="button" value="click" draggable="true"/>
</div>
</div>
</div>
<script type="text/javascript">
var grandPa = document.getElementById('grandPa');
grandPa.addEventListener('click',function () {
alert('grandPa');
})
var father = document.getElementById('father');
father.addEventListener('click',function () {
alert('fattther');
})
var son = document.getElementById('son');
son.addEventListener('click',function () {
alert('son');//最里层div
});
</script>
</body>
</html>
上一篇: 人工智能未来发展趋势
下一篇: 5G学习笔记之NGAP