开发者

set/change value to drop down using jquery

how to set or开发者_如何学C change value to drop down.

I'm having a drop down list which is initially not selected a value.

How can i select a value using jquery


The val() function is used to get and set the value of input controls (including <select>). Grab a jQuery reference to your <select>, and pass its val() function a string matching the value attribute of the <option> that you wish to select:

$("#mySelect").val("15");

This would select the second option in this list:

<select id="mySelect">
    <option value="5">Few</option>
    <option value="15">More</option>
    <option value="100">Many</option>
</select>


$("#id_select").val("value_1");

id_select -> is the id of your select

value_1 -> is one of the values presents in the option of select

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜