Propagation of Event

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 163:- Propagation of Event

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.

18. Understanding DOM

Comments: 2

profile
@niteshguptav63
17-Nov-2024, 01:39 PM

I am not able to access videos from second class and further. I have already completed first class

profile
@niteshguptav63
16-Nov-2024, 10:56 AM

When will I get my course?

profile
@admin79
17-Nov-2024, 01:29 PM

Now, Your query was resolved.

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?