Information About What Happened

When an event fires, the browser automatically creates an event object and passes it as the first argument to your handler function. This object contains all the details about what just occurred.

elem.addEventListener('click', function(event) {
  console.log(event.type);        // "click" — the type of event
  console.log(event.currentTarget); // the element the handler is attached to
  console.log(event.clientX + ':' + event.clientY); // cursor coordinates in the window
});

Key Properties

PropertyDescription
event.typeThe event name (e.g., "click", "keydown")
event.targetThe deepest element that was actually clicked
event.currentTargetThe element the handler is bound to (same as this inside the handler)
event.clientX / clientYMouse cursor coordinates relative to the browser window
event.timeStampWhen the event occurred (milliseconds since page load)
Note

The target property points to the innermost element the user actually clicked. currentTarget points to the element where the event handler is registered. They differ when events bubble up the DOM tree.