2017-07-08 52 views
0

我想在HTML上禁用鼠标滚轮,并从此规则中排除特定的元素。在HTML上禁用鼠标滚轮,并使用jquery排除特定的div

我使用下面的代码:

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

$('.exclude').unbind("mousewheel, touchmove"); 

鼠标滚轮不会在exclude元素上工作,要么。

回答

1

尝试使用jQuery

off()方法筛选

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

拆散()方法在3.0版中被弃用。改用off()方法。

0

与下面的代码,你可以在文档

window.onwheel = e => e.preventDefault = false; 

禁用鼠标滚轮,但我认为这是不可能的,只允许一个子元素轮。

尝试使用CSS

overflow:hidden; 

overflow:auto; 

你会允许滚动

元素
相关问题