且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript计时器循环

更新时间:2022-02-26 06:53:02

请考虑使用setInterval而不是setTimeout。它将自动重复,直到你清除间隔。

Instead of setTimeout, consider using setInterval. It will repeat automatically until you clear the interval.

setInterval(myMethod, 5000);

function myMethod( )
{
  //this will repeat every 5 seconds
  //you can reset counter here
}