JavaScript JavaScript and the DOM Making Changes to the DOM DOM Manipulation

Evandro Delgado
Evandro Delgado
Full Stack JavaScript Techdegree Student 8,129 Points

Need help whit my code. Can someone explain for me?

Bummer: Did you set the 'className' property on the paragraph element to 'panel'?

app.js
var contentDiv = document.getElementById('content');
var newParagraph = document.createElement('p');
 newParagraph.value = ('className', 'panel');
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

Daniel Turato
PRO
Daniel Turato
Java Web Development Techdegree Graduate 30,107 Points

You had the right idea but you can set the className on an element like so:

newParagraph.className = 'panel'
Evandro Delgado
Evandro Delgado
Full Stack JavaScript Techdegree Student 8,129 Points

So if I want to use my idea in the future It will have the same result as newParagraph.className = 'panel'?

Daniel Turato
Daniel Turato
Java Web Development Techdegree Graduate 30,107 Points

Yes so if you want to assign a class to an element through DOM manipulation, you use className