2

我的继续按钮有一个悬停事件,告诉您为什么它被禁用。唯一的问题是启用按钮时无法删除悬停事件....

这行得通

function disable_continue_button(){
    $('#frame_2 > .next')
        .addClass('faded tt')
        .hover(function(){
            $hovered = $(this);
            //tooltip?
            tip = $('.tip.notification.information');
            tip.find('div').html($hovered.attr('tt'));
            tip.fadeIn(150);
        },
        function() {
            tip.hide();   
        })
        .mousemove(function(e) {
            var mousex = e.pageX +40; //Get X coodrinates
            var mousey = e.pageY -20; //Get Y coordinates
            tip.css({top: mousey, left: mousex });
        });    
}

这不起作用

function enable_continue_button(){
    $('#frame_2 > .next')        
        .unbind('mouseenter mouseleave mousemove')
        .removeClass('faded tt');    
}

类被删除了,但悬停工具提示没有被删除......

4

2 回答 2

5

尝试取消绑定 mouseenter、mouseleave、mouseover 和 mouseout。

$('#frame_2 > .next').unbind('mouseenter mouseleave mouseover mouseout');

编辑:

仅取消绑定 mouseenter 和 mouseleave 就足够了。

这是一个显示它工作的示例。当上述 4 个事件未绑定时,工具提示功能将被移除。

.hover(fnEnter, fnLeave)本质上是.mouseenter(fnEnter).mouseleave(fnLeave).

由于并非所有浏览器都本机支持这两个事件(如果我没记错的话,只有 IE 支持),mouseenter()映射到mouseover()mouseleave()映射到mouseout(),在每种情况下都有一些额外的逻辑来模拟事件。

于 2011-02-06T18:49:28.980 回答
0

这个相关的问题可能会帮助您取消绑定所有内容,然后您可以重新绑定您需要的内容?如何使用jquery取消绑定所有事件

于 2011-02-06T17:28:50.863 回答