Facebook Pixel

What is event capturing in JavaScript?

The downward phase of event propagation, from the document down to the target's parent. Listen in the capturing phase with addEventListener(type, handler, true). By default, listeners run in the bubbling phase (false).

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Event Bubbling, Capturing, and Delegation in JavaScript

When an event on a child element propagates up to its parents. A click on a button inside a div triggers the button's listener, then the div's listener, then the body's, up to the document. By default, listeners run in the bubbling phase.

Adding one listener to a parent instead of many listeners to children. Use event.target to determine which child was clicked. This is memory-efficient and works for dynamically added children without needing new listeners.

event.target is the element that triggered the event (the actual clicked element). event.currentTarget is the element the listener is registered on (the element with addEventListener). In delegation, target is the child, currentTarget is the parent.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.