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

Obe Juarez
Obe Juarez
5,903 Points

className is not it?

Its asking me to set the class name for my new class and it doesnt work. but its right isnt it?

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

Clayton Perszyk
MOD
Clayton Perszyk
Treehouse Moderator 46,595 Points

className is a property not a method, so need to assign value to it:

newParagraph.className = 'panel' // Do NOT add period
Obe Juarez
Obe Juarez
5,903 Points

Thank you!!!!