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) Traversing the DOM Using previousElementSibling and insertBefore

Don'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> ?

Perhaps you could elaborate? If you are referring to let ul = li.parentNode, it is because ul has to be selected in order to be used. Think of it as a more specific version of document.querySelector().

So, I think you answered your own question: The reason he uses parent.node is because li is a child node of ul. But we needed to select the parent to use it in the first place.

1 Answer

I 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.