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 DOM Manipulation

Stuck on a challenge task

I have been stuck for a couple hours on the last task of a challenge and maybe another set of eyes can see what is wrong in my code. It is specifically the last line of code that is not working.

app.js
var contentDiv = document.getElementById('content');
var newParagraph=document.createElement('p') ;
newParagraph.className=('panel');
newParagraph.AppendChild('contentDiv');
index.html
<!DOCTYPE html>
<html>
    <head>
        <title>DOM Manipulation</title>
    </head>
    <link rel="stylesheet" href="style.css" />
    <body>
        <div id="content">

        </div>
        <script src="app.js"></script>
    </body>
</html>

2 Answers

Hi Ryan,

Your so close. You just need to swap contentDiv and newParagraph around. contentDiv is the parent you want to append the new child too. newParagraph is the new child element.

Cheers Chris

var contentDiv = document.getElementById('content'); var newParagraph = document.createElement('p') ; newParagraph.className = ('panel'); contentDiv.AppendChild('newParagraph');

The above has a few errors and if not caught, will reject the answer. Try this instead: contentDiv.appendChild(newParagraph);

The A is lowercase and the '' removed.

At least this version worked for me.