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.

HTML Build an Interactive Website Introduction to jQuery Using jQuery to Select Elements

Scott Becker
Scott Becker
20,349 Points

The JQuery Task 2 goes over a string not discussed in the video?

.nav ul li?

3 Answers

Think of it as if you're describing the element. You want to first select the unordered list with the class of nav and then select the list items in it.

So it would be $("ul.nav li"); without spaces between the element and its class or id. I honestly don't know why this is the way it is. But it's the only way it worked for me.

Hope this helps.

Scott Becker
Scott Becker
20,349 Points

Thanks, Ali (and Errin)... that makes sense.

Also, remember that jQuery uses the same CSS specifications. So you would use the $(""); then input css rules and specifications if thats what the questions is calling for. "string" is used when you select a selector to write code in jQuery. You have to use the dollar sign, parentheses, quotes, and a semi-colon. $(""); to write jQuery.

http://api.jquery.com/category/selectors/attribute-selectors/