jQuery - to disable scroll on body

0 votes
168 views
added Jun 20, 2019 in jQuery by LC Marshal Captain (25,770 points)
$(shareBox).each(function () {
  $(this).on('click', function(){
    $(this).removeClass('in');
    $(shareBtn).removeClass('on-click');
    $('.share-news-content > img.ico').attr('src', defIco);
    $('html, body').css({ overflow: 'auto',height: 'auto'});
  });

  $(shareBtn).on('click', function(){
    $('html, body').css({overflow: 'hidden', height: '100%'});
    $(shareBox).addClass('in');
    $('.share-news-content > img.ico').attr('src', closeIco);
    $(this).addClass('on-click');
  });
});

 

1 Response

0 votes
responded Jun 27, 2019 by LC Marshal Captain (25,770 points)
//disable scroll with css overflow
$(shareBtn).modal().on('shown', function(){
    $('body').css('overflow', 'hidden');
}).on('hidden', function(){
    $('body').css('overflow', 'auto');
})

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...