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 Traversal Review

How to select a parent node and store it in a constantDiv?

I'm having trouble finding the answer to a quiz question. Here is the question: In the code below, the constant div contains a reference to a DOM element. Select its parent node and store that in the constant parentOfDiv

const div = document.querySelector('div'); const parentOfDiv =

4 Answers

I got the right answer with: const parentOfDiv = div.parentNode;

In the code below, the constant div contains a reference to a DOM element. Select its parent node and store that in the constant parentOfDiv const div = document.querySelector('div'); const parentOfDiv =

The parentNode property of div can access its parent. what will be the parent node for constantDiv plz help me

Jonathan Rhodes
Jonathan Rhodes
8,086 Points

const parentOfDiv = div.parentNode;

Jonathan Rhodes
Jonathan Rhodes
8,086 Points

The parentNode property of div can access its parent.

Could someone Explain me, how its really works? Thanks for everyone hlep.