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 trialMike Salomone
15,610 PointsWhy select ul and then remove child rather than just typing listItem.remove()?
title says it all.
2 Answers
John Coolidge
12,614 PointsAfter browsing the Mozilla Development Network, I couldn't find any real difference between the two as far as browser compatibility was concerned. I do know that with removeChild() you can save the removed child in a variable to be appended later on.
var oldChild = parent.removeChild(child);
John
Ron Starski
1,997 PointsremoveChild() works on every browser while remove() is not that universal. On MDN remove() is marked as an experimental feature.