I have an html select,
<select id="myselect">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
I need to add a new option to this selection. If I try like this:
$('#myselect').appendTo($('<option>my-option</option>'));
my option added to the end
<select id="myselect">
<option>1</option>
<option>2</option>
<option>3</option>
<option>my-option</option>
</select>
How to add a parameter at the beginning (like the first)? Like this:
<select id="myselect">
<option>my-option</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
source
share