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

nicolaslemaire
nicolaslemaire
12,806 Points

span without form?

Hi there, on this video, I would like to ask you a question; how come we need to say: $('form span').hide();

wouldn't it possible to just say: $('span')? since we want to add ALL spans into our coding here. Is it always necessary to add the "parent" of our specific element to get things done correctly? Thanks in advance.

2 Answers

Totally depends on the situation. In this instance yes you could, only because you want to hide all span tags. When you start building complicated layouts you will want to make sure your selectors are specific enough not to cause unwanted layout issues.

nicolaslemaire
nicolaslemaire
12,806 Points

That's what I thought, thanks Jason :)