撞到了墙上,需要一些帮助
我正在做一个项目,基本上..当你将鼠标悬停在图像上时,我需要它“暂停”。当你向外移动鼠标时,它会切换回来。
我让它工作过一次...但是因为我要解除事件的绑定,所以它只起作用一次。
能把我引向正确的方向吗?将不胜感激
下面是我的代码片段:
$("#card1").mouseenter(function(){
$("#overlay1").css("z-index","30").show("slide", { direction: "down" }, 700);
$("#pope1").css("z-index","30").hide("slide", { direction: "down" }, 700);
$(this).unbind("mouseenter")
});
$("#card1").mouseleave(function(){
$("#overlay1").css("z-index","30").hide("slide", { direction: "down" }, 700);
$("#pope1").css("z-index","30").show("slide", { direction: "down" }, 700);
$(this).unbind("mouseleave")
});发布于 2013-03-07 05:10:55
我认为在这种情况下,您不一定需要解除任何事件的绑定。尝试将代码更改为此jsFiddle的设置方式:http://jsfiddle.net/CMbQB/
$('div').on('mouseover mouseout', function(e){
if(e.type === "mouseover") {
//mouse over events
}
else if(e.type === "mouseout") {
//mouse out events
}
});https://stackoverflow.com/questions/15257750
复制相似问题