Mouse Scroll Lock

Asked

Viewed 64 times

2

How to block the scroll Whell mouse in a div using Javascript or jQuery?

  • Block the scroll of the mouse wheel so that only the scroll by clicking and dragging the scrollbar work, that’s it?

  • Block the scroll mouse wheel.

1 answer

3


You can do it this way with Javascript:

document.getElementById('meuID').onwheel = function(){ return false; }
body {height:1000px;}
#meuID {
    width:150px;
    height:200px;
    border:1px solid #000;
    overflow-y: scroll;
}
<div id="meuID">
    <div style="height:1200px;"></div>
</div>

  • 1

    +1, but I recommend using overflow-y with value "auto" instead of "scroll".

  • Truth @Dorivalzanetto! I built this example of enterprise and the scroll was the value that was in the xD wave

Browser other questions tagged

You are not signed in. Login or sign up in order to post.