1

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.

1
  • Show your markup, that jQuery should work. Commented Oct 9, 2009 at 16:24

3 Answers 3

2

Just take the space out and it should work:

$("label[for=P500_CB_TRANSFERUNIVERSITY]")
Sign up to request clarification or add additional context in comments.

1 Comment

Nice catch, I didn't even notice it.
1

Try:

$('label[for=P500_CB_TRANSFERUNIVERSITY]')

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

Comments

0

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

$("label[for='P500_CB_TRANSFERUNIVERSITY']") 

3 Comments

Quotes aren't needed because there's no spaces.
The inner quotes aren't the problem. The issue is the space between label and [.
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.