saik0o saik0o - 2 months ago 6
jQuery Question

Use jQuery to check mousewheel event without scrollbar

How to check mousewheel movement without scrollbar?

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

Answer

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.

Comments