Javascript banner image.

In the Hello World! Javascript primer our Javascript ran as soon as the script loaded in the browser. Javascript is event-driven: scripts run when a specific HTML event occurs in an HTML document. In the Hello World! example, the event is the loading of the page. In this example, we will use the onclick event.

	<title>Javascript's onclick event</title>

<h1>The onclick Event</h1>
<img src="sicon_mini.gif" id="pageLogo" alt="The stylus logo." onclick="myFunction()" />

function myFunction() {
	alert("You clicked, Lord Master?");


See the Pen Javascript’s onclick() event by David Fox (@foxbeefly) on CodePen.

By MisterFoxOnline

CAT Educator

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.