【问题标题】:How to display selected text of multiselect dropdown in label using jquery?如何使用jquery在标签中显示多选下拉列表的选定文本?
【发布时间】:2016-09-13 01:29:58
【问题描述】:

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

当我选择这个元素应该显示在标签中,

到目前为止尝试的代码:

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

【问题讨论】:

  • 请提供到目前为止您做了什么。谢谢!
  • $('#AttendeeLists').multiselect({ enableFiltering: true, includeSelectAllOption: true });

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


【解决方案1】:

我发现适合我的解决方案

$('#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);
    }
}); 

【讨论】:

    猜你喜欢
    • 2016-01-28
    • 2015-08-04
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-19
    • 1970-01-01
    相关资源
    最近更新 更多