任务是检测鼠标是否经过位于另一个块下方的块。
有2块
.front{
position: absolute;
top: 0;
width: 200px;
height: 200px;
opacity: .2;
background: blue;
}
.back{
position: absolute;
top: 50px;
left: 50px;
width: 100px;
height: 100px;
background: red;
}
<div class="back"></div>
<div class="front"></div>
Normal mouseenter,当然,不会工作:
$('.back').mouseenter(()=>{console.log('+');});
不要提供较低的块克隆z-index,我自己猜到了,但这会激发很多额外的 html 代码,我不想这样做。一定有更聪明的东西......
可以通过css属性pointer-events解决