vincent marc Villafuerte vincent marc Villafuerte - 2 months ago 15
PHP Question

how to select the default value of selectpicker using document ready?

I know it can be than by like this

<option value="3" selected>3 minutes</option>




but the I need it on Jquery because the value will come from ajax database.

<div class="col-lg-6">
Log out after
<select class="selectpicker" id="session_pick" name="session_pick" value="30">
<option value="3">3 minutes</option>
<option value="15">15 minutes</option>
<option value="30">30 minutes</option>
</select>
</div>



Answer

You can select values using selectpicker methods

$('#session_pick').selectpicker('val', '3');

Reference:- https://silviomoreto.github.io/bootstrap-select/methods/#selectpickerval

Comments