How to make the first option of <select> selected with jQuery

omg picture omg · Sep 12, 2009 · Viewed 733k times · Source

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

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

Answer

David Andres picture David Andres · Sep 12, 2009
$("#target").val($("#target option:first").val());