Event Object in JavaScript

From the DOM Manipulation cheat sheet · Events - Basics · verified Jul 2026

Event Object

Access event properties and control event behavior

javascript
// Event properties
function handleClick(event) {
  event.target          // Element that triggered event
  event.currentTarget   // Element with listener
  event.type           // Event type (e.g., 'click')
  event.timeStamp      // When event occurred
  
  // Prevent default action
  event.preventDefault()
  
  // Stop propagation
  event.stopPropagation()
}
💡 target vs currentTarget is important for delegation
⚠️ preventDefault doesn't stop propagation
📌 Use event.key for keyboard events, not keyCode
✅ Check cancelable before calling preventDefault

More JavaScript tasks

Back to the full DOM Manipulation cheat sheet