If you don't paste your elements into other scroll elements (in most cases), you can use this simple high-performance approach:
$(document).ready(function () { $('.self-scroll').on('mouseover', function () { document.body.style.overflow='hidden'; }); $('.self-scroll').on('mouseout', function () { document.body.style.overflow='auto'; }); });
Now, if you apply the self-scroll class to any element, it will not scroll the body.
Iman mohamadi
source share