Описание тега event-bubbling
The concept of parent elements handling events that are propagated by a child element
In event bubbling, an event is propagated through the ancestors of the element that initially receives the event.
For example:
<div id='main' onclick='mainCode();'>
<div id='kid1' onclick='myVar=1;'></div>
<div id='kid2' onclick='myVar=2;'></div>
</div>
The click
event bubbles, and so is propagated to the main
<div>
element after being handled by a kid
<div>
element.
This can make code simpler to understand, for example if mainCode()
has access to the myVar
variable, determining which kid
sent the message is easy.