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

Adil Ismaaeel
Adil Ismaaeel
8,499 Points

Assign element to variable

Create a paragraph element and assign it to the newParagraph variable.

Ive tried everything mentioned in the last two sections but Im not sure what I am doing wrong. Please help

app.js
var contentDiv = document.getElementById('content');
var newParagraph = document.getElementById('p');
index.html
<!DOCTYPE html>
<html>
    <head>
        <title>DOM Manipulation</title>
    </head>
    <link rel="stylesheet" href="style.css" />
    <body>
        <div id="content">
          <p>This is a paragraph</p>    
        </div>
        <script src="app.js"></script>
    </body>
</html>

1 Answer

anthony amaro
anthony amaro
8,166 Points

the question says Create a paragraph element and assign it to the newParagraph variable. you are trying to get an element with an id of p. the way to create an element

const pa = document.createElement('p');

hope this helps