Good day! There is a script modal window that opens with a click. I cannot edit this code, namely, specify the delay function in it.
jQuery(document).ready(function () { jQuery('.open_login').click(function(e) { e.preventDefault(); jQuery('body').css({overflow: 'hidden',}); jQuery('.login_lightbox').fadeIn(800); jQuery('.login_overlay').fadeIn(800); }); jQuery('.login_close').click(function(e) { e.preventDefault(); jQuery('.login_overlay').fadeOut(0); jQuery('.login_lightbox').fadeOut(0); jQuery('body').css({overflow: 'auto',}); }); }); Below in the page code this script is duplicated.
jQuery(document).ready(function () { var delay = 30; $('.login_overlay').delay(delay * 1000).fadeIn(800,function(){ jQuery('body').css({overflow: 'hidden',}); jQuery('.login_lightbox').fadeIn(800); jQuery('.login_overlay').fadeIn(800); }); jQuery('.login_close').click(function(e) { e.preventDefault(); jQuery('.login_overlay').fadeOut(0); jQuery('.login_lightbox').fadeOut(0); jQuery('body').css({overflow: 'auto',}); }); }); This is done to automatically open the window after a certain time. But at the same time, of course, there is one problem: it is impossible to open the window by clicking before it opens automatically. After it opens itself, by clicking it you can already open it. How to fix this error? Thank you for your help! https://jsfiddle.net/LADYX/428ay5np/1/
setTimeout()withdelay * 1000, and when the timer expires, trigger theclickevent on'.open_login'$('.open_login').trigger('click')? - Dmitry