说你有一些像这样的代码:儿童元素点击事件触发父点击事件
<html>
<head>
</head>
<body>
<div id="parentDiv" onclick="alert('parentDiv');">
<div id="childDiv" onclick="alert('childDiv');">
</div>
</div>
</body>
</html>
我不想触发,当我点击childDiv
的parentDiv
点击事件,我该怎么做?
更新
此外,什么是这两个事件的执行顺序?
这就是所谓的事件冒泡,好点开始: - HTTP://计算器。com/questions/4616694/what-is-event-bubbling-and-capturing – Pranav