Hide and disable scrollbar when lightbox opens?

Is it possible to hide and disable the scrollbar when the lightbox opens, then re enable once it closes or gets clicked away?

I using this short code template if that helps in my page builder.

[image class=“my-video-class” src=“image” link=“true” href=“youtube-link”]
[lightbox selector=".my-video-class"]

I found this code, which works

(function($){
$( “.my-lightbox-link-class” ).click(function() {
$(‘html, body’).css({‘overflow’: ‘hidden’, ‘height’: ‘100%’});
});
})(jQuery);

Then added this below in js customiser with the above,

(function($){
$( “.ilightbox-close” ).click(function() {
$(‘html, body’).removeAttr( ‘style’ );
});
})(jQuery);

but doesn’t re enable the scroll after the lightbox exits which another post suggests it should.

Any suggestions on how I can achieve what I want?

Hi there,

Thanks for writing around! Can you please share the URL of the page so we can take a look? Also please remove the scripts as well.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.