Use jQuery to check mousewheel event without scrollbar

saik0o picture saik0o · Sep 18, 2013 · Viewed 55k times · Source

How to check mousewheel movement without scrollbar?

$(document).mousewheel(function() {
     clicker.html("a7a");
});

Answer

Aaron picture Aaron · Sep 18, 2013

I highly recommend you use this jQuery plugin: PLUGIN

Without a plugin, try this example: EXAMPLE

HTML:

<div id='foo' style='height:300px; width:300px; background-color:red'></div>

Javascript:

$('#foo').bind('mousewheel', function(e) {
    if(e.originalEvent.wheelDelta / 120 > 0) {
        alert('up');
    } else {
        alert('down');
    }
});

There is no scrollbar on the div but the wheel event is detected.