Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


useCapture (EventTarget.addEventListener)

for what purpose third property i.e. useCapture of addEventListener used ?

1 Answer

The use capture parameter is for capturing nested events, which is a bit difficult to understand without knowing how the DOM handles capturing and bubbling.

Take a look at this diagram and the accompanying docs to get a bit better of an idea : https://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-phases

And this article breaks it down a bit more: