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:

  1. onmouseover
  2. Triggers an Event as the mouse hovers over it:


  3. onmouseout
  4. Triggers an Event as the mouse moves away:


  5. onkeydown / onkeyup
  6. Triggers an Event as the user types:

    Write something:


  7. onkeypress
  8. 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!