The delay statement of javascript is "setTimeout(function() { remind(); }, 5000);" or "setInterval(function() { remind() }, 5000);".
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
What is the delay statement in javascript?
JavaScript delay function
1.setTimeout function
setTimeout(function() { remind(); }, 5000); //5秒后将会调用执行remind()函数
2.setInterval function
var interval; interval = setInterval(function() { remind() }, 5000); //5秒循环调用执行remind()函数 clearInterval(interval); //清除延时程序
3.Discover An example of
var timer; if (login.state !== undefined) { if (login.state) { var fen = login.info.fen; var xianbey = login.info.xianBey clearTimeout(timer); //清除延时程序 } } else { timer = setTimeout(arguments.callee, 1); //延时循环执行自己 }
[Recommended learning: javascript basic tutorial]
The above is the detailed content of What is the delay statement in javascript. For more information, please follow other related articles on the PHP Chinese website!