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 trial

Trevor Fletcher
2,815 Points.remove() VS. style.display = 'none'
Is there a reason why you would choose to use the .remove() method in your function versus what Dave instructed. Would you want the element to remain in your DOM, but hidden versus being removed altogether once the function is called? Just curious...
function sendAJAX() {
xhr.send();
document.getElementById("Select").remove()
};
1 Answer

Steven Parker
242,296 PointsYou might want to remove an element that won't be used again to adjust the positions of the remaining elements in the tree for CSS purposes, such as when you're using :nth-child
and :first-child
and the like.
But other times you might only want it to temporarily disappear and later bring it back again, so "display: none
" might be the better choice.