views:

31

answers:

1

I'm trying to run this jQuery selector:

$("#label option[value=\"newLabel\"]")

On the following code:

<select name="label" id="label"> 
    <option value="1" label="testLabel">testLabel</option> 
    <option value="newLabel" label="New Label">New Label</option> 
</select>

But the selector just won't find it - can anyone spot where I'm going wrong?

+1  A: 

Remove the quotes in the selector, i.e.:

$("#label option[value=newLabel]")
azatoth
Sorry this didn't work.
Ross
@Ross see http://jsfiddle.net/n7GjN/ it works there
azatoth
@azatoth If that works for you I suspect this is a browser bug then. I'm running Chrome on Ubuntu and that doesn't change the value. I'll try it in FF.
Ross
@azatoth Works in FF 3.6 so I'll report this, thanks.
Ross
You probably want to put it in quotes: `$("#label option[value='newLabel']")` if you are having trouble with it.
Doug Neiner