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

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction Event Bubbling and Delegation

If the event moves to parent and ancestor elements, doesn't that mean the event handler code would act on all of them?

If the event moves to other elements, does that mean the code in the function handler applies to all of those other elements technically (which we don't want)?

1 Answer

What do you mean by 'act'? However, it is the event that is bubbling not the event listener. The ancestor elements get notified that the event has happened. if there is a listener attached to the ancestor for the same event then it would be executed. If no listener attached to the ancestor for the same event, nothing is going to be executed.