Har*_*ldo 2 javascript jquery events unbind
我的继续按钮有一个悬停事件,告诉你为什么它被禁用.唯一的问题是我启用按钮时无法删除悬停事件....
这很有效
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 });
});
}
Run Code Online (Sandbox Code Playgroud)
这不起作用
function enable_continue_button(){
$('#frame_2 > .next')
.unbind('mouseenter mouseleave mousemove')
.removeClass('faded tt');
}
Run Code Online (Sandbox Code Playgroud)
这些类被删除了,但是没有删除悬停工具提示......
尝试解除绑定mouseenter,mouseleave,mouseover和mouseout.
$('#frame_2 > .next').unbind('mouseenter mouseleave mouseover mouseout');
Run Code Online (Sandbox Code Playgroud)
编辑:
仅仅解除鼠标中心和鼠标距离就足够了.
这是一个展示它工作的例子.当上述4个事件未绑定时,将删除工具提示功能.
.hover(fnEnter, fnLeave)基本上是简写.mouseenter(fnEnter).mouseleave(fnLeave).
由于并非所有浏览器本身都支持这两个事件,(如果我没记错,只有IE确实如此),mouseenter()映射到mouseover()并mouseleave()映射到mouseout(),在每种情况下都有一些额外的逻辑来模拟事件.
| 归档时间: |
|
| 查看次数: |
3619 次 |
| 最近记录: |