Event bubbling is a method of event propagation in the HTML DOM API when an event is in an element inside another element, and both elements have registered a handle to that event. It is a process that starts with the element that triggered the event and then bubbles up to the containing elements in the hierarchy. In event bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements.
addEventListener(type, listener, useCapture)
- type: Use to refer to the type of event.
- listener: Function we want to call when the event of the specified type occurs.
- userCapture: Boolean value. Boolean value indicates event phase. By Default useCapture is false. It means it is in the bubbling phase.
After Clicking on the Parent button:
After Clicking on the Child button:
From above example we understand that in bubbling the innermost element’s event is handled first and then the outer: the <p> element’s click event is handled first, then the <div> element’s click event.
- HTML | DOM fullscreenerror Event
- HTML | DOM onvolumechange Event
- HTML | DOM onopen Event
- HTML | DOM ondragleave Event
- HTML | oninvalid Event Attribute
- HTML | DOM onpaste Event
- jQuery | Selectors and Event Methods
- preventDefault() Event Method
- HTML | onsubmit Event Attribute
- jQuery | event.timeStamp property with Example
- HTML | onunload Event Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.