<style>
#a{
width: 300px;
height: 300px;
background-color: pink;
}
#b{
width: 100px;
height: 100px;
background-color: gainsboro;
position: absolute;
top: 50px;
left: 50px;
pointer-events: none;
}
</style>
<body>
<div id="a">1111111111</div>
<div id="b">222222222</div>
</body>
</html>
<script>
document.getElementById('a').addEventListener('click',()=>{
console.log('a');
})
document.getElementById('b').onclick = () => {
console.log('b');
}
</script>
当点击b盒子触发b的事件,但是a的事件触发不了,如何使两个盒子都触发呢。
将b放在子级