views:

21

answers:

1

I have the next select:

<select name="priority" id="priority" class="update_priority">
    <option value="root" label="Without parent">Without parent</option>
    <option value="72" label="Rank3">Rank3</option>
    <option value="71" label="Rank1">Rank1</option>
    <option value="67" label="Rank2">Rank2</option>
    <option value="64" label="Rank4">Rank4</option>
</select>

In JS i have a variable with something value. For example:

selected = 71;

Now, with help of jQuery I want to make option selected with this value(in our example 71).

+7  A: 

you don't need jquery for this. you can just use plain old javascript:

document.getElementById("priority").value = "71";

But if you still want to with jquery you can do the same thing:

$("#priority").val("71")

EDIT: Here is an example. You can comment out either one you want to see the other one work: http://jsfiddle.net/BupWA/

spinon
Thanks. It is work.
Alexander.Plutov