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 trialThomas H
Full Stack JavaScript Techdegree Student 4,545 PointsParent Transversal
Hi everybody,
I don't find the way to solve the second task, i used the removeChild method but it doesnt work, someone have a hint ?
Thank you
var removeMe = document.querySelector('.remove_me');
var parent = removeMe.parentNode;
parent.removeChild('removeMe');
<!DOCTYPE html>
<html>
<head>
<title>Parent Traversal</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<ul>
<li>Hello</li>
<li>Hi</li>
<li class="remove_me">Good bye!</li>
<li>Howdy</li>
</ul>
<script src="app.js"></script>
</body>
</html>
4 Answers
anthony amaro
8,686 Pointssorry about that. your code its almost correct but when you remove an element is the variable name. and you are using a string.
parent.removeChild('removeMe'); // this is a string
it should be
parent.removeChild(removeMe); // with no quotations marks
Thomas H
Full Stack JavaScript Techdegree Student 4,545 PointsI found the solution :)
var removeMe = document.querySelector('.remove_me'); var parent = removeMe.parentNode; parent.removeChild(removeMe);
anthony amaro
8,686 PointsOn line 2 of app.js, traverse to the parent element of the removeMe element.
if you read the question again, it doesn't say anything about removing the element..
just remove this
parent.removeChild('removeMe');
and you should be fine
Thomas H
Full Stack JavaScript Techdegree Student 4,545 PointsThank you but actually my question is about the second task "Next, remove the removeMe element from the parent element." ;)