js for 循环 等待时间

参考链接:https://docs.pingcode.com/baike/2504176

var fish = document.getElementsByClassName('fish');
fish[0].click();

function delay(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function executeWithDelay() {
    for (let i = 0; i < 999999; i++) {
        fish[0].click();
        await delay(1);
    }
}
executeWithDelay()
文章目录