[英]Scrollbar not restored on modal hide
I have a modal and is opened by clicking on button. 我有一个模态,可以通过单击按钮打开。 When this modal is opened then i am getting 2 scroll bars, 打开此模式后,我会看到2个滚动条,
I tried removing scrollbar as below: 我尝试删除滚动条,如下所示:
if ($(".dialog-popup-open").length > 0) {
$('html').css('overflow','hidden');
}
$(".closeButton").off("click").on("click", function () {
$('html').css('overflow','scroll');
//$('html').css('overflow','inherit');
}
Scroll bar is hiding perfectly but not restoring when modal is closed. 滚动条完美隐藏,但模式关闭时无法恢复。 Any ideas please? 有什么想法吗?
i tried both scroll
and inherit
我尝试了scroll
和inherit
Can you please try this one: 你能试试这个吗:
$("#openModal").click(function(){ //code to open the overlay //.... //.... //add modalActive class to html tag $("html").addClass("modalActive"); }); $(".closeButton").off("click").on("click", function () { //code to close the modal overlay //... //... //remove modalActive class from html $('html').removeClass("modalActive"); });
.modalActive{ overflow: hidden; }
你需要把它给body
:
$('body').css('overflow','auto');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.