multiselect checkbox dropdown

前端 未结 2 1822
感情败类
感情败类 2021-02-10 06:40

I am using multiselect checkbox dropdown.

Please look example jsfiddle

$(function () { $(\'#lstStates\').multiselect({ }); });

Once you

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-10 06:56

    You can use buttonText option of multiselect.

    http://jsfiddle.net/ejqngpn5/

    $('#lstStates').multiselect({ 
        buttonText: function(options, select) {
            console.log(select[0].length);
            if (options.length === 0) {
                return 'None selected';
            }
            if (options.length === select[0].length) {
                return 'All selected ('+select[0].length+')';
            }
            else if (options.length >= 4) {
                return options.length + ' selected';
            }
            else {
                var labels = [];
                console.log(options);
                options.each(function() {
                    labels.push($(this).val());
                });
                return labels.join(', ') + '';
            }
        }
    
    });
    

提交回复
热议问题