Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select value on combobox with jquery

I have a combobox (select) and i want to select after a specified value something like that

$("mySelect").select(myValue);

Thanks

like image 769
tinti Avatar asked Jun 18 '11 13:06

tinti


1 Answers

If you want to select the <option> element associated with your value, you can use val():

<select id="mySelect">
    <option value="foo">Foo</option>
    <option value="bar">Bar</option>
    <option value="quux">Quux</option>
</select>

$("#mySelect").val("quux");
like image 59
Frédéric Hamidi Avatar answered Oct 21 '22 14:10

Frédéric Hamidi