Set Interval()


Method



What does it do?


It performs a function or piece of code repetively every
time the time period ends and it's executed every delay milliseconds.


The setInterval() method will continue calling the function until clearInterval()
is called, or the window is closed. If you dont use clearInterval() when you click
on the button it won't work because it's still being called by the setInterval

Syntax


setInterval(function, milliseconds, param1, param2, ...)




Example 1

Example 2

Example 3