Calling a function every 60 seconds

后端 未结 13 2097
情书的邮戳
情书的邮戳 2020-11-22 08:24

Using setTimeout() it is possible to launch a function at a specified time:

setTimeout(function, 60000);

But what if I would l

13条回答
  •  心在旅途
    2020-11-22 09:12

    A good example where to subscribe a setInterval(), and use a clearInterval() to stop the forever loop:

    function myTimer() {
    
    }
    
    var timer = setInterval(myTimer, 5000);
    

    call this line to stop the loop:

    clearInterval(timer);
    

提交回复
热议问题