Browser Events

Event Target

Every Node object in our DOM can trigger an event. The object that triggers our particular event is called the target:

In the above example, the p element is the target for both mouseover and mouseout events. We listen to these events on the p element and change the color of the text depending on which event was triggered.

The event parameter that we see in our addEventListener is an event object. It is automatically passed to all event handlers. It helps in passing extra information like the target to the event handler.