jquery - jquery 对话框关闭时页面滚动消失

标签 jquery css

关闭对话框前我的代码...

 $('body').css('overflow','hidden');
 $('.ui-widget-overlay').css('width','100%');
 $('#content').removeClass('lightbox_bg');
 $('#saveDialog').dialog('close');

我的 CSS...

<style>
.lightbox_bg {
    background:rgb(153,153,153) none repeat scroll 0 0; 
    left:0;
    filter:alpha(opacity=50);
    opacity: 0.5;
    top:0;
    width:100%;
    z-index:50;        
    position:fixed;
}
.modal{
    position:absolute;       
    z-index:51;        
}

当对话框打开时,滚动保持不变,但当它关闭时,滚动消失,使页面保持在同一位置。任何想法。谢谢。

最佳答案

是的,因为你有这条线

 $('body').css('overflow','hidden'); // Setting overflow hidden on body and thus removing the scroll bar

删除此行,它将使您的滚动条返回。

关于jquery - jquery 对话框关闭时页面滚动消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33707489/

相关文章:

jQuery jPicker 颜色选择器 : How to convert from 8 digit (w Transparency) to standard 6 digit hex?

javascript - 当系列中不存在日期时,Highstock 比较先前的数据点

javascript - jQuery - 如果没有选择任何选项不起作用则发出警报

javascript - 将嵌入代码包装在一个人选择的链接中

html - 最大高度等于最大宽度

jquery - 动态捕获一个div位置

jQueryUI 可选 : can't apply theme to selected item ("ui-selected" class)

javascript - 如何在 Javascript 表格中将图像居中

javascript - 未能对先前事件的元素调用操作

html Iframe 创建白色背景