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! While you're at it, check out some resources Treehouse students have shared here.
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 trialChanel Weathers
7,003 PointsIm certain Ive assigned <p> to the variable, but it keeps giving me an error, not understanding why.
I added a <p> element to the HTML & I assigned the newParagraph variable to the <p> element in the js file using the querySelector method which I believe is correct but still getting and error.
var contentDiv = document.getElementById('content');
let newParagraph = document.querySelector('p');
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
</div>
<p class="para"></p>
<script src="app.js"></script>
</body>
</html>
2 Answers
Piotr Manczak
Front End Web Development Techdegree Graduate 29,363 PointsAs far as I can understand you created <p> directly in HTML but they are asking you to do that in JavaScript, like that:
var contentDiv = document.getElementById('content'); var newParagraph = document.createElement('p');
and next: newParagraph.className = 'panel'; and then:
contentDiv.appendChild(newParagraph);
if that helps don't forget to upvote me, please.
Josh Ballard
697 PointsHi Chanel,
Can you post the error message? You created a new paragraph element, but you haven't appended it to the DOM. Is that what you are referring to?
-Josh
Chanel Weathers
7,003 PointsChanel Weathers
7,003 PointsThanks!! looks like i was using the wrong method.