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 Introduction to jQuery Hello, jQuery! Selecting Page Elements with jQuery

Joy Miller
Joy Miller
6,612 Points

Shouldn't the attribute selectors be a string? $("[name='newsletter']"). Video and teacher notes exclude those outer "

Shouldn't the attribute selectors be a string? $("[name='newsletter']"). Both the video and teacher notes exclude those outer quotes and say that this is the correct format:

$([name='newsletter'])

However, api.jquery.com gives this as one of their attribute selector examples: $( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );

...so I'm assuming that the attribute selectors DO need to be strings, just like other types (tags, classes, and IDs).

Oliver Duncan
Oliver Duncan
16,642 Points

I could be wrong, but I think either one works. Maybe jQuery supports a lot of different formats for its selectors. I know, for instance, that single quotes also work for selecting an element (i.e. $('form').submit). Bottom line: pick one way of formatting your selectors and stick to it.

Thanks for clarifying this, Joy. This is the third correction needed in the first four videos.

Aisha Blake
Aisha Blake
Treehouse Guest Teacher

Thanks for tagging me, Jason! There's not much I can do about this right now, but hopefully someone on staff (I'm a guest teacher) will be able to fix this relatively quickly.

I'm sorry to those who were confused by this! In the future, I'll have to be better about running every single line of code (even if I'm not using it in a working example) just in case.

Lee Zamastil you mentioned other errors? Would you mind describing them or sending a message to support? Several people check these courses before they're released, but it's pretty likely that things will slip through the cracks. I imagine that's even more true with teachers new to the platform like me!

Aisha Blake, happily the issues mentioned have been addressed in the community questions sections. The first is regarding "Items do not change when clicked". Jessica, a user, provided the solution. The second issue is "Error in Workspace Code". User Matthew provided both the problem and the answer. And Joy helped explain this one about the selectors as a string.

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

I've updated the teacher's notes, hopefully that'll clear up some confusion.

2 Answers

Yes, they definitely need to be, otherwise things will get interpreted as variables and arrays, etc.

Matt Ramsden
Matt Ramsden
14,152 Points

Yes indeed it should