How to make the first option of selected with jQuery

Posted in :

How do I make the first option of selected with jQuery?

<select id="target">
  <option value="1">...</option>
  <option value="2">...</option>
</select>

Ans:

$("#target").val($("#target option:first").val());

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *