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 trialJames Matthews
21,610 PointsRemoving an Element from the DOM task 3/3
I'm causing an error but I don't quite know what it is :/
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<ul>
<li id="first">First Item</li>
<li id="second">Second Item</li>
<li id="third">Third Item</li>
</ul>
<script src="app.js"></script>
</body>
</html>
let myList = document.getElementsByTagName('ul')[0];
let firstListItem = document.querySelector('li:first-child');
firstListItem.removeChild(li);
1 Answer
Steven Parker
231,248 Points
The calling format for removeChild is parent
.removeChild(child
);.
Conveniently, in task 1 you identified the parent element, and in task 2 you identified the child. So in task 3, you just need to construct the call by filling in the other variables in the right places.
James Matthews
21,610 PointsJames Matthews
21,610 PointsAh yes, of course, Thanks Steven!
Steven Parker
231,248 PointsSteven Parker
231,248 PointsHey, James Matthews — did you accidentally hit the wrong button, or was I the victim of a "drive-by downvoting"?
James Matthews
21,610 PointsJames Matthews
21,610 PointsHello Steven, I can assure you I did not down-vote, and marked as best answer, so I assume you were indeed a victim! I have given you a +1 though, just to counter it ;)
Steven Parker
231,248 PointsSteven Parker
231,248 PointsI wasn't concerned about the point, just wondered if it was an error. But thanks!