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

Dione Marshall
Dione Marshall
6,184 Points

How do you set the class?

Need help setting the class.

app.js
let newParagraph=document.createElement('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>

2 Answers

Tray Denney
PLUS
Tray Denney
Courses Plus Student 12,884 Points

Hey Dione! To set the class means to set the class name of the newParagraph element.

I have tested this method on the challenge and it worked but I don't feel that giving you the entire answer is beneficial to your learning so here is some documentation for how to set a class to an element. Hope this helps and good luck!

https://developer.mozilla.org/en-US/docs/Web/API/Element/className

Dione Marshall
Dione Marshall
6,184 Points

Yeah still having trouble the way the question is worded is confusing me.

Briain Corroon
Briain Corroon
13,689 Points
newParagraph.className = "panel";

This adds the class "panel" to the paragraph element.