How do I clear the dropdownlist values on button click event using jQuery?
This question is related to
jquery
button
drop-down-menu
click
If you want to reset bootstrap page with button click using jQuery :
function resetForm(){
var validator = $( "#form_ID" ).validate();
validator.resetForm();
}
Using above code you also have change the field colour as red to normal.
If you want to reset only fielded value then :
$("#form_ID")[0].reset();
$('#dropdownid').empty();
That will remove all <option>
elements underneath the dropdown element.
If you want to unselect selected items, go with the code from Russ.
If you want to reset the selected options
$('select option:selected').removeAttr('selected');
If you actually want to remove the options (although I don't think you mean this).
$('select').empty();
Substitute select
for the most appropriate selector in your case (this may be by id or by CSS class). Using as is will reset all <select>
elements on the page
Source: Stackoverflow.com