JavaScript Example 06

Using buttons to trigger JavaScript routines:

 

The button above is unformatted, but the one below uses style .timebutton to make it more interesting:

 

Clicking on the button below calls a function that replaces text that is in a <span>...</span> in the paragraph below it:

The current time is (the time will appear here)

Note that I placed this function script at the END of the body instead of in the head of the document so that it would not cause delay in downloading and rendering the rest of the document. Because this script is not actually called until a button is clicked, this works out fine.