且构网

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

用于javascript中的循环延迟

更新时间:2023-02-18 15:11:02

Use setInterval()

var i = 0;

var interval = setInterval(function(){
    setValue();
    i += 1;

    if(i == 10)
        clearInterval(interval);
}, 2000);

There is no way to sleep for 2sec without freezing the whole browser. Javascript is single threaded.

相关阅读

技术问答最新文章