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 trialMing Chi Wong
2,909 PointsDon't quite understand the use of parent node in this video?
Why does he use parent.node when <li> is a child node of <ul> ?
1 Answer
Soufiane Ez Zine
Full Stack JavaScript Techdegree Graduate 17,754 PointsI think I understand his question, I was scratching my head over it for a while until I understood. the parentNode actually refers to the parent of the button node, which, in this case, is the li node. because overall the button is the target of the event.
Jesse Vorvick
6,047 PointsJesse Vorvick
6,047 PointsPerhaps you could elaborate? If you are referring to
let ul = li.parentNode
, it is becauseul
has to be selected in order to be used. Think of it as a more specific version ofdocument.querySelector()
.So, I think you answered your own question: The reason he uses parent.node is because
li
is a child node oful
. But we needed to select the parent to use it in the first place.