如何使用jquery在标签中显示多选下拉列表的选定文本?

时间:2016-05-17 05:26:41

标签: javascript jquery asp.net-mvc twitter-bootstrap

我正在使用Bootstrap Multiselect dropdown。我想在标签中显示所选文本。如果我取消选择该元素应从标签中删除。

当我选择此元素时,应显示在标签中,

Image

到目前为止尝试过的代码:

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

1 个答案:

答案 0 :(得分:0)

**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);
    }
}); 
相关问题