0

Using Bootstrap 3 and Bootstrap Select Plugin I have a select options list at This Demo . Now I would like to reset the select option to First option ("Select From The List") when ever user Clicks on Reset btn. I already tried this:

$('#resetForm').on("click", function(){ $("#selopt").val($("#selopt option:first").val()); }); <select class="selectpicker" id="selopt"> <option value="0">Select From List</option> <option value="1">Volvo</option> <option value="2">Saab</option> <option value="3">Mercedes</option> <option value="4">Audi</option> </select> <br> <button id="resetForm" class="btn btn-success">Reset</button> 

but this is not doing the job! Can you please let me know how to do this? Thanks

1 Answer 1

2

You need to use 'deselect' to reset your selectpicker as:

$('#resetForm').on("click", function(){ **$("#selopt").selectpicker('deselectAll');** }); <select class="selectpicker" id="selopt"> <option value="0">Select From List</option> <option value="1">Volvo</option> <option value="2">Saab</option> <option value="3">Mercedes</option> <option value="4">Audi</option> </select> 


Reset

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.