简体   繁体   English

经过一段时间延迟后,引导程序模式窗口循环通过

[英]Bootstrap modal window loop through after some delay

I'm using bootstrap modal window, it is working fine. 我正在使用引导模式窗口,它工作正常。 But i want it to loop through after some delay even the user close the pop up as many times... 但是我希望它在经过一些延迟后即​​使用户关闭弹出窗口也要循环多次...

$(window).load(function(){
   setTimeout(function(){
       $('#myCounter').modal('show');
   }, 5000);
});

How can i make it loop after every 5 seconds? 我如何每5秒循环一次?

Thanks in advance 提前致谢

  function function_name(){
             setTimeout(function(){
               $('#myCounter').modal('show');
             function_name(); // call function
           }, 5000);
        }       
 $(window).load(function(){
        function_name();    
    });

The setInterval() method will help you to loop and it will continue to call the function until clearInterval() function is called, or the window is closed. setInterval()方法将帮助您循环,它将继续调用该函数,直到调用clearInterval()函数或关闭窗口为止。

you can try the code attached below: 您可以尝试以下附带的代码:

 $(window).load(function(){setInterval(function () { $('#myModal').modal('show');},2000);});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM