Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM DOM Manipulation

These instructions are not descriptive enough.

set the class of panel to newParagraph?

app.js
const contentDiv = document.getElementById("content");
let newParagraph = document.createElement('p');

document.panel.className = 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>

1 Answer

brandon downs
brandon downs
11,577 Points

you created a variable named newParagraph. now they are asking you to set newParagraph to have a class of panel.

to do this you simply write the variable name, and then can call the className method on that variable and assign it to panel

check out this code,

const contentDiv = document.getElementById("content");
let newParagraph = document.createElement('p');

newParagraph.className = 'panel';

I figured it out, but I have run into a few of these where the descriptions for the tasks honestly aren't that clear even after a video. It would have made more sense if it said something like, "add a class to newParagraph called panel". The description was like reading wisdom from Yoda.