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

Haardik Gupta
Haardik Gupta
Full Stack JavaScript Techdegree Student 5,275 Points

set the class attribute to equal panel.

var contentDiv = document.getElementById('content'); var newParagraph = document.createElement('p'); var newParagraph.className = panel;

this is my code an d it is giving me a syntax error i do not know what i am doing wrong i need help please

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

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,537 Points

1) You declared newParagraph with var in the second line. No need to use var again in line 3

2) The class name should be enclosed in quotes

So for line 3 you'd have:

newParagraph.className = "panel"