Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // To execute a function every two seconds, you do this:
- var interval = setInterval(function() { alert("Hello"); }, 2000);
- // Then to clear the interval (I.E. Stop it) you just do this:
- clearInterval(interval);
- // And to execute a function once after a certain amount of time, you simply use this instead:
- var timeout = setTimeout(function() { alert("Hello"); }, 2000);
- // And to clear the timeout (I.E. Stop it before executing the function) you do this:
- clearTimeout(timeout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement