Take the 2-minute tour ×

Can someone please let me know the correct way to select an element type with a given attribute? In my particular case I'm trying to access a label with a an attribute of "for" that has a value of "P500_CB_TRANSFERUNIVERSITY".

I would have though the propery jQuery syntax would be something like
$('label [for=P500_CB_TRANSFERUNIVERSITY]') but that doesn't seem to work.

share|improve this question
Show your markup, that jQuery should work. –  ChaosPandion Oct 9 '09 at 16:24
add comment

3 Answers

up vote 2 down vote accepted

Just take the space out and it should work:

share|improve this answer
Nice catch, I didn't even notice it. –  ChaosPandion Oct 9 '09 at 17:32
add comment



which is exactly the same, just with the space removed.

share|improve this answer
add comment

Looks like you are missing quotes around the attribute value. This should work fine:

share|improve this answer
Quotes aren't needed because there's no spaces. –  Sonny Boy Oct 9 '09 at 16:27
The inner quotes aren't the problem. The issue is the space between label and [. –  Andrew Oct 9 '09 at 16:29
ahh didn't even notice the space. I always use quotes, must be out of habit so I thought it was the proper way to do it –  Mark Oct 9 '09 at 17:14
add comment

Your Answer


