如何删除 jQuery 添加的 $.hover 事件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1558365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:42:59  来源:igfitidea点击:

How to remove $.hover event added by jQuery?

jqueryevents

提问by Mask

I tried $.unbind('hover'), which is not working.

我试过$.unbind('hover'),这是行不通的。

回答by CMS

The hoverfunction it's just a short-handto bind two handlers to the mouseenterand mouseleaveevents, you should unbind them:

悬停功能,它只是一个短期的手结合两个处理到了mouseenter鼠标离开事件,你应该拆散他们。

$('#item').unbind('mouseenter mouseleave');

回答by diynevala

Api documentation on hover:

关于悬停的API 文档

Example: To unbind the above example use:

示例:要取消绑定上述示例,请使用:

$("td").off('mouseenter mouseleave');

回答by user460064

tringger unbinding with a click

单击一下即可解除绑定

$('.item').click(function() { 
 $('.item').unbind('mouseenter mouseleave');
});

回答by cam8001

You could also try:

你也可以试试:

$('#item').bind('hover', function(){return false})

$('#item').bind('hover', function(){return false})