Bootstrap Multiselect Get Selected Values


Answer :

the solution what I found to work in my case

$('#multiselect1').multiselect({     selectAllValue: 'multiselect-all',     enableCaseInsensitiveFiltering: true,     enableFiltering: true,     maxHeight: '300',     buttonWidth: '235',     onChange: function(element, checked) {         var brands = $('#multiselect1 option:selected');         var selected = [];         $(brands).each(function(index, brand){             selected.push([$(this).val()]);         });          console.log(selected);     } });  

Shorter version:

$('#multiselect1').multiselect({     ...     onChange: function() {         console.log($('#multiselect1').val());     } });  

more efficient, due to less DOM lookups:

$('#multiselect1').multiselect({     // ...     onChange: function() {         var selected = this.$select.val();         // ...     } }); 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable