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