Table of Contents

DOM - Event delegation (bubbling, propagation)

About

Event delegation allows to:

events are attached by default to the elements

Using event propagation (bubbling) to handle events at a higher level in the DOM than the element on which the event originated.

You bubbles up or down the DOM

Example

Jquery

<ul>
  <li><a href="#">First</a></li>
  <li><a href="#">Second</a></li>
  <li><a href="#">Third</a></li>
</ul>
$( "ul" ).on( "click", "a", function( event ) {
    event.preventDefault();
    console.log( $( this ).text() );
});

Documentation / Reference