bootstrap multiselect get selected values

前端 未结 7 1531
难免孤独
难免孤独 2021-01-31 16:39

How do I get back on onChange all selected values in my multiselect dropdown. Used plugin here. Trying to use the following but I think I\'m on the wrong track

$         


        
7条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 17:28

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

提交回复
热议问题