I want to disable mousewheel on HTML, and exclude a specific element from this rule.
I am using the following code:
$('html').bind("mousewheel, touchmove", function(e) {
e.stopPropagation();
return false;
});
$('.exclude').unbind("mousewheel, touchmove");
Mouse Wheel does not work on the exclude
element either.
Try to use off()
method of jQuery
Like this
$(".exclude").off("mousewheel, touchmove");
The unbind() method was deprecated in version 3.0. Use the off() method instead.
with following code you can disable mousewheel on document
window.onwheel = e => e.preventDefault = false;
but i think it is impossible to allow only an child element to wheel.
Try to use css
overflow:hidden;
and
overflow:auto;
for the elements you will allowed to scroll
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.