Ross
Ross

Reputation: 47007

Selecting an option by its value

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?

Upvotes: 1

Views: 162

Answers (1)

azatoth
azatoth

Reputation: 2379

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

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

Upvotes: 1

Related Questions