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 Password Confirmation Form Perform: Part 1

Nadine Schermerhorn
Nadine Schermerhorn
2,324 Points

When using .hide or .show, how do you determine which element to use as a selector (how far up?)

On the span tag, I thought it would be the paragraph tag because it was the closest tag that was surrounding the span tag yet in the video, you said it was the form tag. Why is this? and how do I know how far up the line I need to go?

1 Answer

18,266 Points

If you select the paragraph you also hide the inputs. Selecting isn't about what the oldest parent. It's about selecting what you need to hide.

The hints are hidden and are wrapped in span therefore it's good to hide that. If you go higher selecting the paragraph you hide everything.