📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials jQuery in Practice Event Object

Event Object

5 min read
The event object has useful properties: e.target is the clicked element, e.preventDefault() stops the default action, and e.stopPropagation() stops bubbling up the DOM tree to parent elements.

The Event Object

$('a').on('click', function(e) {
  e.preventDefault();   // stop default action
  e.stopPropagation();  // stop bubbling
  console.log(e.type);  // 'click'
  console.log(e.target); // clicked element
  console.log(e.pageX, e.pageY); // coordinates
});