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!

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.

let newParagraph=document.createElement('p');
<!DOCTYPE html>
        <title>DOM Manipulation</title>
    <link rel="stylesheet" href="style.css" />
        <div id="content">

        <script src="app.js"></script>

2 Answers

Tray Denney
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!


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.