Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset value of Bootstrap-select after button click

Without "option:selected"

$("#dataPicker").val('default');
$("#dataPicker").selectpicker("refresh");

You can write it in one single line reduces extra piece of code.

$("#dataPicker").val('default').selectpicker("refresh");

you can easily solve this problem by adding the autocomplete attribute to the select-element and set it to "off".

<select id="dataPicker" class="selectpicker form-control" autocomplete="off">
  <option value="default" selected="selected">Default</option>
  <option value="one">One</option>
  <option value="two">Two</option>
  <option value="three">Three</option>
</select>