Let’s say I’ve got a function called repeatMe(). I want this to be called every 3 seconds. I do it like this:
3000 is the delay in milliseconds. We might want to stop this at some point though, so it’s better to assign this to a variable so that we can refer back to it later. Something like this:
myHandler = setInterval("repeatMe()", 3000);
So now we can assign the following code to, for example, a button:
How about just delaying something so that it happens 3 seconds after it’s supposed to happen? Let’s say I’ve got a function called inabit(). I could assign the following code to a button:
The inabit() function would be called 3000 milliseconds after the button was clicked.