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

A little help with the last exercise please?? It wants me to append newParagraph to divContent... Thanks in advance!

I can't figure out how this final task out... Here is what I have for question 3/3:

const contentDiv = document.getElementById("content"); let newParagraph = document.createElement("p"); newParagraph.className = "panel"; contentDiv.appendChild("p.newParagraph");

app.js
const contentDiv = document.getElementById("content");
let newParagraph = document.createElement("p");
newParagraph.className = "panel";
contentDiv.appendChild("p.newParagraph");
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>

3 Answers

Stephen Gheysens
Stephen Gheysens
11,935 Points

Hi Christopher,

Everything looks good in your Javascript file up until line 4. Let's see if this helps you figure out what's wrong:

ā€¢ You've retrieved the contentDiv and stored it in a variable

ā€¢ You've created a new paragraph element and stored it as newParagraph

ā€¢ You've correctly set the class of newParagraph to "panel"

Now, all that you need to do is add newParagraph to contentDiv with the appendChild method <- You're really close, just check out the example in this documentation and I think you can figure out how you might be using it incorrectly.

Abinet Kenore
Abinet Kenore
10,082 Points

contentDiv.appendChild(newParagraph); // This for part #3

Thanks a bunch!! I removed the paranthesis, and WALA!! Correct-o-mundo.

Thanks again!