Article: Delete / Remove / Clear all items (options) from DropDownList using JavaScript and jQuery
function loadFarmer(call) {
var selectedFarmer = call.value;
if(selectedFarmer==''){
$('.farmer').empty();
$('#f.id').val(" ").select2(); */
$('farmer').removeAttr(' ');
$('.farmer').find('option:not(:first)').remove();
}
$.post("dynamicCertification_populateFarmer", {selectedVillage: selectedFarmer}, function (data) {
insertOptions($('.farmer').attr("id"),$.parseJSON(data));
});
$('#farmerId').select2();
}
<div class="filterEle flexi flexi12 farmerClass " style="width:220px;">
<label for="branchIdParam"><s:property value="%{getLocaleProperty('village')}" /></label>
<div class="form-element">
<s:select cssClass="form-control input-sm cond select2" name="village"
list="villageList" id="v.code" headerKey=""
headerValue="%{getText('txt.select')}"
onchange="loadFarmer(this);" />
</div>
</div>