Dynamically adding and removing items to select jquery
Here is the example to add and removing items dynamically using jquery to select
html
<select id="List" class="form-control pull-left" style='width:40%'>
<option value="select">Select</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="new">new</option>
<option value="old">old</option>
</select>
<input type="button" id="delete"
value="delete" class="btn btn-danger" />
<br />
<input type='text' id="readme" class='form-control pull-left' style="width:40%" /><input id="add" class="btn btn-success" type="button" value="add" /><br />
<div class="result"></div>
JQUERY
$('#add').on('click',function(){
$("#List").append('<option>'+$('#readme').val()+'</option>');
$('.result').html('1 item added to select list').hide(2000);
});
$('#delete').on('click',function(){
$("#List option:selected").remove();
$('.result').html('1 item deleted to select list').hide(2000);
});
Demo: