swiecaJS
My thougths on JavaScript, AWS Cloud and other aspects of being Software Engineer
Bubbling means that:
<form>
<input id="name" type="text">
<input id="surname" type="text">
<div>
<p id="clicker" >Click me please!</p>
</div>
</form>
Thanks to that we can, for example, have an event listener on a <form>
and listen on all child events in one global handler.
The solution for it is event.stopPropagation()
. I It will stop event propagation but only on the current handler. That means when you have multiple handlers for an event, you will stop only current one
addEventListener(..., true)
can take up the third parameter - which inverses the way of event journey. I.e. the event will propagate down in ancestors hierarchy.
See the Pen #Bubbling by Karol Świeca (@khazarr) on CodePen.
level-four
has an event.stopPropagation
inside - when bubbling path is drawn. See what it changes
See the Pen #Bubbling - stop propagation by Karol Świeca (@khazarr) on CodePen.