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 The Event Object

Hector Galicia-Milla
Hector Galicia-Milla
8,064 Points

targeting ul instead of div

would it have been better to target the event listener to the ul ancestor instead of the div, this way he would not need to add the conditional statement to make sure the event goes to a li tag. Or is it better to have the conditional statement for more specificity?

Scott Junner
Scott Junner
9,010 Points

You are probably right. But really the focus here is on teaching you how to traverse the DOM. How to move about and access various child or parent nodes and demonstrate bubbling.

So, yeah, in practice your suggestion would probably be a better idea, but now you know how to target stuff a couple of layers deep.

1 Answer