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 trialPiotr Manczak
Front End Web Development Techdegree Graduate 29,363 Pointselement.remove();
Wouldn't it be easier to do: const extra = document.querySelector(".extra"); extra.remove();
This way, selected node would be removed from the DOM without engaging parent element, as opposed to parent.removeChild(child) method. It worked in my solution. Have I used it somehow incorrectly?
2 Answers
Travis Alstrand
Treehouse Project ReviewerYour code is totally valid! Nice find!
I'm not sure what course you're in, is it navigating the DOM? If so, then they probably went this route to show a way of doing so with DOM traversal.
Piotr Manczak
Front End Web Development Techdegree Graduate 29,363 PointsThanks Travis. Happy coding!
Travis Alstrand
Treehouse Project ReviewerYou're welcome