Javascript 在HTML上禁用鼠标滚轮并使用jquery排除特定div
我想在HTML上禁用鼠标滚轮,并从该规则中排除特定元素 我正在使用以下代码: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').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;