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) Making Changes to the DOM Appending and Removing Nodes

Killeon Patterson
Killeon Patterson
18,527 Points

Place the new element p as the last child

Am I not suppose to be using last-child in the instance?

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi there Killeon,

I'm not exactly sure what you are asking, so I will just waffle on. In this question you have a div element and a paragraph element. You want to add the paragraph element as the last child of the div element. When any element is added using appendChild() it is inserted at the end, making it the last child element.

div.appendChild(p);

In this case, the p element will be added to the div element, and will be the last child.