the advantages of event delegation

What event delegation ?

DOM event delegation is a mechanism of responding to ui-events via a single common parent rather than each child, through the magic of event "bubbling".

Advantages

Event delegation has main advantages:

  1. Fewer functions to manage.
  2. Takes up less memory.
  3. Fewer ties between your code and the DOM.
  4. Don’t need to worry about removing event handlers when changing the DOM via innerHTML.

扩展阅读

  1. Event delegation in JavaScript
  2. Understanding Event Delegation
  3. Working with Events, Part 3: More Event Delegation with jQuery

你可能感兴趣的:(JavaScript,jquery,dom,event,delegation)