on~:
Throughout this site, we have been using DOM Events to either alert, print or display things, either in self-declaring functions or on the click of a button.
The Event used has been onclick. All JavaScript DOM Events start with on.
There are many more than this one, however. Below, we'll try a few:
onmouseoveronmouseoutonkeydown/onkeyuponkeypress
Triggers an Event as the mouse hovers over it:
Triggers an Event as the mouse moves away:
Triggers an Event as the user types:
Write something:
Triggers an Event as the user types:
In the code above, you'll notice an extra piece of code, addEventListener. We shall go into this here. But before we do, double click the button below!