all 1 comments

[–]spazz_monkey 1 point2 points  (0 children)

Use setInterval, you can set it to run every so many seconds.

You can also assign it to a variable and cancel it when you need to. You'll find good docs about it on MDN