Javascript TUTORIAL
Javascript Timer
Let us make a form based clock that displays time in the 24 hour format.
|
Save the file as say timer.htm. If you open the file in a browser it will produce the following.
Explanation
We use the Date() object to get the hours, minutes, seconds of the day. setTimeoiut() evaluates an expression or calls a function after a certain amount of time, specified in milliseconds. We use setTimeout() to call the update() function every one second. So the clock in the text element is updated every second.
You can try this example online at the link below, which will open in a new window.
Javascript Timer Example
Here is another example that displays the characters of a string at defined interval ( like in typewriter).
|
You can try this example online at the link below, which will open in a new window.
Javascript Timer Example