It is impossible to remove the scroll bar when the modal window is open, I tried using overflow-y:hidden with the addition of a function, but nothing happened. What should I do to remove the scroll bar in the modal window, well, actually to appear when you close it?

The code and everything is here. https://dropmefiles.com/48oP6 Password: NioD8D

Javascript:

 $(document).ready(function() { setTimeout(popup, 3000); function popup() { $("#logindiv").css("display", "block"); } $("#login #cancel").click(function () { $(this).parent().parent().hide(); }); $("#onclick, #onclick1, #onclick2").click(function () { $("#contactdiv").css("display", "block"); }); $("#contact #cancel").click(function () { $(this).parent().parent().hide(); }); }); 

Styles:

 #contactdiv{ z-index: 10; opacity:0.92; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; background: #000; display: none; } #logindiv{ opacity:0.92; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; background: #000; display: none; } 
  • one
    you would show the working code, and you could talk about where scrolling is user33274
  • The only thing I can say about your codes is that instead of .css("display", "block") , you can use .show() , and then there is no dark forest, it's not clear even which element needs to remove the scroll bar - MasterAlex

1 answer 1

Actually, I figured it out myself, corrected the code on (provided below, and it all worked). :)

  $(document).ready(function() { setTimeout(popup, 3000); function popup() { $("#logindiv").css("display", "block"); $('body').css('overflow','hidden') } $("#login #cancel").click(function() { $('body').css('overflow-y','scroll') $(this).parent().parent().hide(); }); $("#onclick, #onclick1, #onclick2").click(function() { $('body').css('overflow','hidden') $("#contactdiv").css("display", "block"); }); $("#contact #cancel").click(function() { $('body').css('overflow-y','scroll') $(this).parent().parent().hide(); });