How to create pause or delay in FOR loop?

前端 未结 12 1544
长情又很酷
长情又很酷 2021-02-01 19:57

I am working on a website, where I need to create a pause or delay.
So please tell me How to create pause or delay in for loop in javascript or

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 20:29

    I tried all one, but I think this code is better one, it is very simple code.

    var s = document.getElementById("div1");
    var i = 0;
    setInterval(function () {s.innerHTML = s.innerHTML + i.toString();  i++;}, 2000);
    

提交回复
热议问题