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 trialSumalee Juntra
8,669 PointsHow to create a paragraph element and assign it to the newParagraph variable.
Create a paragraph element and assign it to the newParagraph variable.
var contentDiv = document.getElementById('content');
var p = document.querySelector('.newParagraph');
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
<p class="newParagraph"></p>
</div>
<script src="app.js"></script>
</body>
</html>
2 Answers
Xavier Ritch
11,099 PointsHey! We meet again. You probably already got it figured by now but just in case...... It seems you're missing the variable declaration for newParagraph, so add that first. Once thats done, the challenge is asking to create a new paragraph (<p>) html element using javascript, so the createElement() method would need to be used on the document object in order to do this and add an argument of "p" for the paragraph element to be created. then we would store that in the newParagraph variable. So it should look like this:
var contentDiv = document.getElementById('content');
var newParagraph;
newParagraph = document.createElement("p");
Blake Larson
13,014 PointsThey want you to create it with javascript. You are grabbing from the DOM because it already exists.
var newParagraph = document.createElement("P");
Sumalee Juntra
8,669 PointsThanks so much. ;)
Laura Owens
15,044 PointsShould the ("P") be lowercase like this ("p") or does it matter?
Sumalee Juntra
8,669 PointsSumalee Juntra
8,669 PointsThanks so much Xavier Ritch. ;)
Mauricio Hernandez
7,208 PointsMauricio Hernandez
7,208 PointsThank you, God bless you.