There are likely a few issues with this code:
- Unless setup otherwise, the
HTML
element will be the scrollable element - You are attempthing to access a jQuery function on a vanilla javascript
this
- You are not actually executing that function to get the value
-
You are not calling the funciton to set the desired value
$(function() { // Change 'body' to 'html' $('html').bind('mousewheel', function(event) { event.preventDefault(); var $window = $(this); // <--- Wrap the event target with a jQuery object var scrollTop = $window.scrollTop(); // <--- Call this function to return the result (use parens) /* Otherwise the reference on this line is to a function, not a value, and call the function (instead of setting a property) */ $window.scrollTop(scrollTop + ((event.deltaY * event.deltaFactor) * -1)); }); });