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!
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
eric nzenga2,661 Points
remove() vs hide()
I tried using hide() instead of remove() and it worked too. Why remove() is a better choice? Thank you
Josh Alling17,172 Points
It depends on what you want to accomplish, because remove and hide do different things. Hide will change the css to display none, so that element is still in the dom, but it's hidden. Remove will actually delete the element and it's contents. If you need to hide an element temporarily and show it again later, use hide(). If you know that you won't need the element on the page anymore, use remove().