Create a Timer in Javascript | Treehouse Quick Tip
To get a feel for TeamTreeHouse content
Sometimes you need to wait a certain amount of time in your program before taking an action. You may also want to repeat an action after a certain length of time.
You can do this using a timeOut and an interval.
In this example tutorial, the element is replaced using getElementById.
You can create a timeOut that will wait a certain length of time after the page loads before executing the code. This is accomplished with the setTimeout function.
You can continually update your function using the setInterval function.
You can cancel the Timeout or Interval using the clearInterval or clearTimeout functions.
Follow us on Twitter:
http://twitter.com/treehouse
Find us on Facebook:
https://www.facebook.com/TeamTreehouse