How do you run function after so many seconds
like if I had a button that would call a function, how would I make it work so the function works after a few seconds after the button is clicked?
Printable View
How do you run function after so many seconds
like if I had a button that would call a function, how would I make it work so the function works after a few seconds after the button is clicked?
See the sticky post at the top of this forum about setInterval() - that's what you're looking for.
code:
millisecondsToDelay = 4*1000; // 4 seconds
myFutureFunction = function()
{
clearInterval(ih);
// do future stuff here...
}
ih = setInterval(myFutureFunction, millisecondsToDelay);
thnx jbum