Event Delegation, also known as Event Delegation. Is a common technique for binding events commonly used in JavaScript. As the name suggests, an event broker is a response event that needs to be bound to a child element (click, keydown……) Delegate to the parent element to take on the role of event listener. Event broker works by bubbling events from DOM elements

The event bubbling

  • Events that click on the child element are passed to the parent element to continue execution

Event firing contains the response,

  • Event source: The object that triggers the event
  • Event names: click,mouseover, etc
  • Event handlers: onclick,onmouseover

Three stages of event firing

  • Capture phase: Conduction from the Window object to the target node (from top to bottom) is called the capture phase, which does not respond to any events
  • Target stage: Triggered from the target stage, known as the target stage
  • Bubbling phase: Conduction from the target node back to the Window object (from bottom to last) is called the bubbling phase
  • To prevent bubbling: e.topPropagation ();