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 trialFemke Boermans
11,240 PointsAppend the newParagraph element to the content DIV element.
Hi Everyone!
Can someone explain to me what I'm doing wrong? Thanks!
const contentDiv = document.getElementById("content");
let newParagraph = document.createElement('p');
newParagraph.className = 'panel';
let div = document.getElementsByTagName('div');
div.appendChild(newParagraph);
<!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>
5 Answers
Jennifer Nordell
Treehouse TeacherHi Femke! If you'll look at line 1 of the code in the challenge you'll see that they already set up a variable name to hold the div with the ID of "content". Your code would select every div in the document given that you're selecting a set of elements with that tag.
Try rereading the instructions for step 3 again, knowing that you've already selected the div element with the ID content and assigned it to a variable in the first line of code.
I hope this helps, but let me know if you're still stuck!
Brent Lane
5,778 PointscontentDiv.appendChild(newParagraph);
Moderator reverted redaction
Jennifer Nordell
Treehouse TeacherHi there, Brent Lane! Treehouse tends to frown on copy/pasteable answers with no explanation given. I will be redacting your answer, but please feel free to repost your answer with an explanation!
Brent Lane
5,778 PointsThat's fine. I will not comment any further after this post. I'll also be terminating my account once the month is up....since TreeHouse is such a tight moderation group with an inferior help or support systeM
Kevin Korte
28,149 PointsBrent, I have to back up Jennifer on this one - I understand you don't like the guidelines, but there is no need to try to make her feel bad for following the guidelines laid out for us. Also, I will challenge that help and support are defined by complete answers with no context and guidance. It's really not helping anyone learn something new. Sorry to see you go, we hope that you stay, but whatever you decide, best of luck to you!
Jennifer Nordell
Treehouse TeacherBrent Lane As it so happened, I took a screenshot of that before I redacted it. After looking at the screenshot, I see that it was indeed not a copy/pasteable answer for this challenge. As such, I'm reverting my redaction. I apologize for not looking at it closer and in regards t the challenge at hand.
Jennifer Nordell
Treehouse TeacherKevin Korte no he's right about the redaction. It was a knee-jerk reaction on my part and I should've read it more carefully. My apologies.
Randell Purington
9,992 PointsThank you because that description wasn't helping me. When I saw your comment I seen where I messed up. You actually helped me. Thank you!
Lee Holcomb
3,535 PointsQuestion, why is it contentDiv.appendChild(newParagraph); and not contentDiv.appendChild("newParagraph");
Not adding the "'s threw me off.
scherwain massaquoi
Courses Plus Student 14,494 PointsLee Holcomb because newParagraph is a variable.
David McGarvey
Full Stack JavaScript Techdegree Graduate 27,424 PointsThanks Jennifer! I too was struggling with this one but your explanation to Femke's question helped guide me through.
Anne Donald
9,847 PointsHi Jennifer...
Thank you from me too, I was struggling with this for a good hour!
nathan goel
7,410 Pointsthe kind of stuff that can drive you crazy when you are a beginer
Femke Boermans
11,240 PointsFemke Boermans
11,240 PointsHi Jennifer!
I got it now! Thank you!