Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在HTML上禁用鼠标滚轮并使用jquery排除特定div_Javascript_Jquery_Html - Fatal编程技术网

Javascript 在HTML上禁用鼠标滚轮并使用jquery排除特定div

Javascript 在HTML上禁用鼠标滚轮并使用jquery排除特定div,javascript,jquery,html,Javascript,Jquery,Html,我想在HTML上禁用鼠标滚轮,并从该规则中排除特定元素 我正在使用以下代码: $('html').bind("mousewheel, touchmove", function(e) { e.stopPropagation(); return false; }); $('.exclude').unbind("mousewheel, touchmove"); 鼠标滚轮在exclude元素上也不起作用。尝试使用jQuery的off()方法 像这样 $(".exclude").off

我想在HTML上禁用鼠标滚轮,并从该规则中排除特定元素

我正在使用以下代码:

$('html').bind("mousewheel, touchmove", function(e) {
    e.stopPropagation();
    return false;
});

$('.exclude').unbind("mousewheel, touchmove");
鼠标滚轮在
exclude
元素上也不起作用。

尝试使用jQuery的
off()
方法

像这样

$(".exclude").off("mousewheel, touchmove");

版本3.0中不推荐使用unbind()方法。请改用off()方法。

通过以下代码,您可以禁用文档上的鼠标滚轮

 window.onwheel = e => e.preventDefault = false;
但我认为不可能只允许一个子元素转动

尝试使用css

overflow:hidden;

对于允许滚动的元素

overflow:auto;