简体   繁体   中英

How to disable mousewheel panning in javascript/jquery?

I have a div, which has

.A {
    max-height:100px;
    overflow-y: hidden;
}

I don't want it to scroll. However I noticed the user can still click down with a mousewheel then move the mouse up or down and it simulates a scroll. The div box goes up and down. How can I disable this?

https://jsfiddle.net/2aoeyfbL/

Thanks

This seems to work all the time, even by pressing tab when there is an input box inside the div.

$('.A').bind("scroll", function(e) {
    this.scrollTop = 0;
});

Fix the position of the div

.A {
    max-height:100px;
    overflow-y: hidden;
    position:fixed;
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM