防止 jQuery 中的滚动事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11185522/
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
Prevent scroll event in jQuery
提问by Denis
Is it possible to prevent scroll event in jQuery?
是否可以防止 jQuery 中的滚动事件?
I've tried this code, but it didn't work.
我试过这段代码,但没有用。
$('*').scroll(function(event){
event.stopPropagation();
event.preventDefault();
return false;
})
采纳答案by Denis
well.. i worked with wrong event. touchmove was exactly what i'm looked for. so
好吧..我处理了错误的事件。touchmove 正是我要找的。所以
$('body').bind('touchmove', function(e){
e.preventDefault();
});
回答by kaleazy
You can disable scrolling within certain element areas using the following:
您可以使用以下方法禁用某些元素区域内的滚动:
$("element,element2").bind("touchmove",function(e){
e.preventDefault();
});
回答by Siva Charan
Just set the body
CSS to disable the scroll.
只需设置body
CSS 以禁用滚动。
body {
overflow: hidden;
}