Home  >  Article  >  Web Front-end  >  What is the delay statement in javascript

What is the delay statement in javascript

藏色散人
藏色散人Original
2021-11-03 15:21:012009browse

The delay statement of javascript is "setTimeout(function() { remind(); }, 5000);" or "setInterval(function() { remind() }, 5000);".

What is the delay statement in javascript

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn