Adrian
Adrian

Reputation: 1

How to disable mouse wheel click in a div?

I'm building an application for my client and I cannot figure out how to disable mouse wheel click in a div. I know you can do it because I've done it before but totally forgot it. Basically, when I hover my mouse over a div, and I click using the mouse wheel and then drag the mouse down, it basically drag down my whole page. Is there a way to just disable the whole action of mouse wheel clicking and then dragging?

Upvotes: 0

Views: 2107

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50787

$(document).on('click', function(e){
    if(e.which == 2){
        e.preventDefault(); //stop default click action from mousewheel
    }
});

jsFiddle

Simply replace document the selector for the div in question.

Upvotes: 1

Related Questions