Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction The Event Object

Hamdi Elshahat
Hamdi Elshahat
2,565 Points

Everything is well explained, But why he didn't select the ul instead of listDiv since ul is the closest parent to li?

The Event Object video everything is well explained, But why he didn't select the ul instead of listDiv since ul is the closest parent to li and it would never be removed even if we remove every single li element?

2 Answers

Steven Parker
Steven Parker
210,070 Points

Selecting the <ul> should work the same for this particular list, but should other lists be added to the <div> later, the choice as shown would extend the highlighting effect to them also.

However, whether this advance planning is intentional or not is not clear from the video.

Because most things have been very unclear so far. He goes from saying parent which is UL to something completely different. I have no idea what he is doing.