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

JavaScript jQuery Basics (2014) Creating a Spoiler Revealer Perform: Part 3

Jenna Malone
Jenna Malone
7,173 Points

Why not just use .hide(); ?

So previously we used .hide(); to hide the text box that flew in in the first project. I am just wondering why for this project we want to actually remove it from the DOM instead of just hiding it? Is there a best practices thing that I am missing here, or are we just removing it from the DOM because thats what the instructor specifically told us to do?

1 Answer

David Gross
David Gross
19,443 Points

hide() sets the matched elements' CSS display property to none.

remove() removes the matched elements from the DOM.

Jenna Malone
Jenna Malone
7,173 Points

That makes sense, thank you!