0

I am trying to enable and disable the scroll using jquery on click event, I have tried it using css and jquery but it didn't worked. Please help me to solve this.

$('.explore-video-btn').click(function(){
       $('body').css('overflow', 'hidden');
       // $('body').off('scroll');
});

$('.close-video-pop-up').click(function(){
    $('body').css('overflow', 'auto');
    // $('body').on('scroll')
});
Shriya
  • 35
  • 1
  • 2
  • 9
  • Possible duplicate of [How to programmatically disable page scrolling with jQuery](https://stackoverflow.com/questions/3656592/how-to-programmatically-disable-page-scrolling-with-jquery) – Sebastian Jan 29 '19 at 06:52
  • It worked when I used ' : ' instead of ' , ' in $('body').css('overflow' : 'auto') but it is not working on ios. – Shriya Jan 31 '19 at 07:55

1 Answers1

0

Try this instead of:

$('.explore-video-btn').click(function(){
   $('body').addClass('o-hidden');
});

$('.close-video-pop-up').click(function(){
    $('body').removeClass('o-hidden');
});

add this css code into your style

.o-hidden {overflow: hidden;}
pk_tan777
  • 351
  • 1
  • 3