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 trialhandy christian
2,899 PointsPlease help I'm stuck on the event challenge, help me solve this problem
Help
const removeMe = document.querySelector('.remove_me');
let parent = removeMe.parentNode;
removeMe.addEventListener('click', (event) => {
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>
3 Answers
Steven Parker
231,271 PointsTask 2 says "Next, remove the removeMe
element from the parent element."
You're pretty close, but I see two issues:
- You don't need an event listener here, just the code to perform the removal.
- The argument to "removeChild" should not have quotes around it.
handy christian
2,899 Points:,) i hope someday i can be like you tho thanks
G Johnson
46,427 PointsThe fix is simple - just remove the quotes around 'removeMe'. Tested on code pen.
No quotes are needed because this is a variable that you set to represent the dom info.
G Johnson
46,427 PointsSteven Parker .. stated this first I see.
handy christian
2,899 Pointshandy christian
2,899 Pointshi Steven Parker, i saw your profile you have a lot of javascript points. I just want to know how old are you and what kind of job you get hired right now? I just want to know so i can be motivated to learn more about programming :D
Steven Parker
231,271 PointsSteven Parker
231,271 PointsLet's just say "
Math.log(my_age) > 4
". When I first started learning about programming, punched cards were a common input medium, and computers took up a whole room.I was already a software engineer (mostly C/C++) when I learned JavaScript. I do more web-oriented stuff now, which is why Treehouse has been great for expanding my skill set.