Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!