Dhruti Dhruti - 6 months ago 38
Javascript Question

How to display selected text of multiselect dropdown in label using jquery?

I am using

Bootstrap Multiselect dropdown
. I want to display selected text in label. If I unselect the element should remove from label.

When I select this element should display in label,

Image

Code tried so far:

$('#AttendeeLists').multiselect({
enableFiltering: true,
includeSelectAllOption: true });

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);
    }
}); 
Comments