Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery disable scroll doesn't work in Firefox

I use this code in other projects and it works fine. I don't know what is wrong in my code. It works fine in Chrome but not in Firefox.

This is my code:

$('body').on({
  'mousewheel': function(e) {
    e.preventDefault();
    e.stopPropagation();
  }
});
body {
  height: 5000px;
}
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

Example jsFiddle.

The jQuery version in my project is 1.11.3.

like image 357
Aram Mkrtchyan Avatar asked Jul 17 '26 01:07

Aram Mkrtchyan


1 Answers

Some browsers have there default "scroll-overflow" not on the body. Instand it is on html or document. Try $('html') or $(document) for example. That could help

like image 127
Time to Travel Avatar answered Jul 19 '26 13:07

Time to Travel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!