JavaScript JavaScript and the DOM 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