If you have any query feel free to chat us!
Happy Coding! Happy Learning!
Event propagation refers to the way in which events flow through the DOM hierarchy. When an event is triggered on an element, it propagates or "bubbles" up the DOM tree until it reaches the document object.
There are two types of event propagation: bubbling and capturing. In the bubbling phase, the event is first captured by the innermost element and then propagated up the hierarchy to the outermost element. In the capturing phase, the event is first captured by the outermost element and then propagated down the hierarchy to the innermost element.
By default, events use the bubbling phase, but you can change this behavior using the addEventListener()
method. The third parameter of this method is a boolean value that indicates whether to use the capturing phase (true
) or the bubbling phase (false
).
When an event is triggered on an element, it is handled by any event listeners attached to that element, and then it propagates up or down the DOM tree depending on the event propagation phase. If an event listener cancels the event by calling event.preventDefault()
, the event will not continue to propagate.
Event propagation can be useful for creating event delegation, which is a technique for handling events on multiple elements using a single event listener. By using event propagation, you can attach a single event listener to a parent element and then use the event.target
property to determine which child element was clicked. This can be more efficient than attaching individual event listeners to each child element.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.