• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

122
Views
how to turn off mousewheel in jquery

I want to disable the mouse wheel in jQuery and I did it but I'm getting this error

jquery.min.js:2 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

This is the code in JS file:

$(document).ready(() => {
  $(window).bind("mousewheel", function() {
    return false;
  });
})
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue is because you cannot call preventDefault() on passive events, such as mousewheel is - among others.

To fix the issue you can set passive: false when you bind the event handler:

window.addEventListener('wheel', e => e.preventDefault(), {
  passive: false
});
/* just to make the scrollbar appear in this demo */
body { height: 5000px; }

However, I would strongly suggest you do not do this. Preventing users from navigating your site using the very popular mouse scroll wheel will be incredibly annoying for you users - and possibly make them believe your site is malfunctioning.

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error