Back to search

Events in JavaScript: event handling, addEventListener, bubbling, capturing, delegation, preventDefault, and stopPropagation

Browser events travel through capture and bubble phases, and good event handling often relies on delegation and controlled propagation.

JavaScript Medium Theory

Events in JavaScript: event handling, addEventListener, bubbling, capturing, delegation, preventDefault, and stopPropagation

Browser events travel through capture and bubble phases, and good event handling often relies on delegation and controlled propagation.

  • `addEventListener` can listen in capture or bubble phase
  • Delegation reduces many per-node listeners
  • `preventDefault` and `stopPropagation` solve different problems

Events in JavaScript: event handling, addEventListener, bubbling, capturing, delegation, preventDefault, and stopPropagation