You'll start this journey by learning how to use HTML attributes to handle events. Admittedly, HTML attribute event handlers aren't used as often as they used to be, but they are very useful when you need to handle an event quickly.
Let's start with an example element. Following is a normal
<div id="myDiv">Hello, Events!</div>
This element has an
myDiv, and it contains a small bit of text. It's an ordinary element now, but you can add some specialness to it by handling the
click event. To handle this event, add an attribute called
onclick to the opening tag, like this:
<div id="myDiv" onclick="">Hello, Events!</div>
The name of an attribute used to handle events is the word
on followed by the name of the event. In this example the event handler
onclick handles the
click event. If you wanted to handle the
mouseover event, the attribute's name would be
Also keep in mind that even though
<div/> elements don't interact with mouse clicks by default, you can add that ...