事件穿透
<div id="parent">
<div id="child">点击我</div>
</div>
<script>
const parent = document.getElementById('parent');
const child = document.getElementById('child');
parent.addEventListener('click', function() {
alert('父元素被点击');
});
child.addEventListener('click', function() {
alert('子元素被点击');
});
</script>Last updated