【问题标题】:jquery mouseneter and unbindjquery mouseenter 和 unbind
【发布时间】:2013-03-06 20:50:56
【问题描述】:

撞到了墙上,需要一些帮助

我正在做一个项目,基本上......当您将鼠标悬停在图像上时,我需要它“暂停”。鼠标移开时,它会切换回来。

我有这个工作一次......但因为我取消绑定事件,它只工作一次。

可以引导我朝着正确的方向前进吗?将不胜感激

这是我的 sn-p:

$("#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")

});

【问题讨论】:

    标签: jquery hover bind mouseenter unbind


    【解决方案1】:

    我认为在这种情况下您不一定需要取消绑定任何事件。尝试将您的代码更改为此 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
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      • 2011-12-23
      • 2023-03-29
      • 1970-01-01
      • 2010-11-18
      相关资源
      最近更新 更多