Unable to scroll on website

There are likely a few issues with this code:

  1. Unless setup otherwise, theHTML element will be the scrollable element
  2. You are attempthing to access a jQuery function on a vanilla javascriptthis
  3. You are not actually executing that function to get the value
  4. 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));
        });
    });
    

Leave a Comment