Set multiple select value in bootstrap selectpicker

<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<script src=""></script>
 <select id="myselect" name="myselect[]" multiple>
   <option value=""></option>
   <option value="1">red</option>
   <option value="2">orange</option>
   <option value="3">green</option>
   <option value="4">blue</option>
$(window).on('load', function() {
   $('#myselect').selectpicker('val', [1, 3, 4]);

I am using above code but still I get Nothing selected.

How do I set multiple values selected in bootstrap selectpicker.

I have tried solution given in below link:

How to set selected value on select using selectpicker plugin from bootstrap

14 thoughts on “Set multiple select value in bootstrap selectpicker”

Leave a Comment