Reputation: 1368
I have a page where when we click a button a Jquery dialog box is called using JQuery. But when it is shown the Window scroll bar is shown in all browsers. How can we avoid this? Can we avoid this uising JQuery? Or is it is better to fix by CSS?.
Upvotes: 0
Views: 623
Reputation: 22395
Just set the overflow on the body tag to hidden, should do the trick:
$('body').css('overflow', 'hidden');
Fiddle: http://jsfiddle.net/garreh/xYatB/1/
Upvotes: 1
Reputation: 17532
css
.hidescrolls {
overflow:hidden;
}
JQ
...click(function (){
// show dialog();
$('body,html').addClass('hidescrolls');
});
make sure you use the $('body,html').removeClass('hidescrolls');
on dialog close/hide
Upvotes: 3