绝对定位块存在问题 - 当我使用$('。my-block')。mouseenter()并在其处理程序中更改高度时 - mouseenter会触发与其他此类块交叉的数量。
例如这样的事情:
.items{position:relative;}
.item{position:absolute;}
<div class="items">
<div class="item item1" style="top:0; z-index:1"></div>
<div class="item item2" style="top:50; z-index:2"></div>
<div class="item item3" style="top:100; z-index:3"></div>
<div class="item item4" style="top:150; z-index:4"></div>
</div>
$('item').hover(function(event){
console.log("mouseenter triggered");
$(this).stop().animate({
height:400px; // it should to grow up direction
},{
step=function(now, fx){
//changing previous items position by some magic with fx.pos and some logic
}
});
event.stopPropagation();
},function(){/*...*/})
or
$('item').mouseenter(function(){
console.log("mouseenter triggered");
event.stopPropagation();
});
所以当我让鼠标在日志浏览器中输入item3时,我会看到字符串“mouseenter triggered”两次,如果item4三次!我可以在这做什么来阻止这种情况?
答案 0 :(得分:0)
$('item').mouseenter(function(event){
console.log("mouseenter triggered");
event.stopPropagation();
});
您没有将事件传递给函数...