I want my body
not to scroll if 'not-scroll'
class is appended on it, otherwise it should work normally.
I have been searching for this problem for 2 days, but can't find any solution working for me.
What I want is to add a class
to body
, and it should not scroll if any one try to scroll on it. But every other element
should scroll, if scrolling is possible in them.
I have already read so many stackoverflow answers, but nothing is workable for me. I have checked out, solution 1,solution 2,solution 3,solution 4 and many others..
PS: Actually, I am implementing fancybox in my application, which opens a model screen on the body
, now if user tries to scroll on the model, body
behind the model view scrolls. I want to prevent this.
I have tried this.
$(document).on('touchmove',function(event) {
if($('body').hasClass('no-scroll')) {
event.preventDefault();
}
});
but it also prevents scrolling inside model view. Any help would be appreciated!!
Thanks in advance.
Scenario is like shown in picture, captured form iPad mini