JavaScript onclick Event Handler
An event handler is an intermediary between user interaction with the website and a behavior executed by JavaScript based on the user interaction. In nearly all cases a user has to engage with the web page's user interface to initiate an onclick or other related event handler; because with the move to rich, dynamic website experiences, user experience is key.
There are two places an event handler can be found.
- as HTML mark-up
- as part of JavaScript's dot syntax
onclick Images as Buttons
This tutorial will explain the onclick event handler and one rudimentary use of events to turn brochure-style websites into dynamic solutions.
In the example below, the images have an onclick event handler included in the mark-up to turn the images into buttons when a user clicks on them.
Click on an image to preview an onclick event handler demonstration.