JavaScript - jQuery interval

后端 未结 5 1101
执笔经年
执笔经年 2020-12-10 04:20

I am using JavaScript with jQuery. I have the following script to alert hi every 30 seconds.

$(document).ready( function() {
    alert(\"hi\");
         


        
5条回答
  •  Happy的楠姐
    2020-12-10 04:43

    You could use setTimeout instead and have the callback reschedule itself.

    $(function() {
        sayHi();
    
        function sayHi() {
           setTimeout(sayHi,30000);
           alert('hi');
        }
    });
    

提交回复
热议问题