I have html select,
<select id="myselect">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
I need to add new option in this select.
If I try like this:
$('#myselect').appendTo($('<option>my-option</option>'));
the my-option have added to the end
<select id="myselect">
<option>1</option>
<option>2</option>
<option>3</option>
<option>my-option</option>
</select>
How can I add an option in the beginning (as first)?
Like this:
<select id="myselect">
<option>my-option</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…