Do something every 5 seconds and the code to stop it. (JQuery)

前端 未结 4 1771
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 05:22

How can I repeat a function doSomething() every 5 seconds.

I also need code that will make it stop doing it.

And code to on-the-fly adjust the f

4条回答
  •  -上瘾入骨i
    2020-12-15 06:12

    Use

    setInterval

    Calls a function repeatedly, with a fixed time delay between each call to that function.

    for repeated action and

    clearInterval

    Cancels repeated action which was set up using setInterval().

    to stop that

提交回复
热议问题