📜  为循环设置超时 JS - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:58.355000             🧑  作者: Mango

代码示例1
window.purls = [11213,23121,43343,5644,77535]
i = 0;
for (i = 0; i < window.purls.length; i++){
    doSetTimeout(i);
}

function doSetTimeout(i) {
    setTimeout(function() {
        // Code goes here
    }, i*1200); //1200 = time in milliseconds
}