A JavaScript event

JavaScript was created to make pages change after they had loaded so the first example was not the best use of it.

To make something happen after a delay you need something to trigger it.  In index.html find the second paragraph and put a new blank line after it.  On that line put this:

<p onmouseup="document.write('NO!');">Tell the truth</p>

Save it.  Load the page in the browser and click on the new paragraph.

There are much better ways of doing things but this gives you an idea.  The JavaScript we just added is inside some HTML which might make it confusing.  This is the HTML:

<p onmouseup="">Tell the truth</p>

This is the JavaScript:


The HTML tells the browser that it should monitor the paragraph for mouse clicks (in a mouse click the button goes down then up).  When the mouse button is released (onmouseup) it should do what is inside the double quotes.

The JavaScript is programming code.  Code is instructions to a computer (to the browser).  This one says change all of the HTML content for the document.   Set it to NO!.

There is much more you can do but any programming gets complicated quite quickly so that's it for now.  You have finished with this example site now so do anything you want to it.  Maybe make a backup called musichtmlcssjavascript first.