JQuery 鼠标滚轮:如何禁用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6702116/
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
JQuery Mousewheel: How to disable?
提问by Dimitri Vorontzov
I am using jquery.mousewheel.js as a part of the jQuery jScrollPane plugin.
我使用 jquery.mousewheel.js 作为 jQuery jScrollPane 插件的一部分。
I want to disable the mousewheel at some point.
我想在某个时候禁用鼠标滚轮。
Could someone please recommend a jQuery statement that can do it?
有人可以推荐一个可以做到这一点的jQuery语句吗?
Thank you!
谢谢!
回答by Mrchief
Something like this:
像这样的东西:
$("#menu").bind("mousewheel", function() {
return false;
});
回答by gentimouton
Try using .unmousewheel()
, it should also work.
尝试使用.unmousewheel()
,它也应该有效。
回答by odam.fm
the container you must unbind is jspPane
您必须解除绑定的容器是 jspPane
In my case i needed to disable it only in the boxes inside #myOuterContainer
在我的情况下,我只需要在里面的框中禁用它 #myOuterContainer
$('#myOuterContainer .jspPane').bind('mousewheel',function(){ return false; });
回答by Kurt Leadley
For those who are not using the jQuery mousewheel plugin, this worked for me:
对于那些不使用 jQuery mousewheel 插件的人,这对我有用:
$("#inputID").bind("wheel", function() {
return false;
});
The only difference is that the .bind
method takes an argument of wheel
instead of mousewheel
唯一的区别是该.bind
方法接受一个参数wheel
而不是mousewheel
Note: The element I applied this to was on an input
of type number
注意:我应用它的元素在input
类型上number