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

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.