+ 1
How to use setinterval?
3 Answers
+ 3
setInterval(function() {
// your code goes here
}, 3000); // time in ms
The setInterval() method calls a function or evaluates an expression at specified intervals. It will continue calling the function until the function clearInterval() is called, or the window is closed.
btw, 1000 ms = 1 second.
+ 2
In addition to what @Nenad__ said, if you're using setinterval on a pre-defined function, do not include the function parentheses.
setfunction(func, 3000s)
+ 1
Take a look at this example I did so you can have a better understanding:
https://code.sololearn.com/WtWo50WAHrTt/#js



