multiselect checkbox dropdown

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

I am using multiselect checkbox dropdown.

Please look example jsfiddle

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

Once you

2条回答
  •  醉酒成梦
    2021-02-10 07:19

    Use buttonText option of multiSelect Plugin. The Parameter options give you all the option you select. Then format your buttonText value as you want.

    Script

    $(function () {
       $('#lstStates').multiselect({
          buttonText: function(options){
             if (options.length === 0) {
                return 'No option selected ...';
             }
    
             var labels = [];
             options.each(function() {
               if ($(this).attr('value') !== undefined) {
                   labels.push($(this).attr('value'));
               } 
             });
            return labels.join(', ');  
         }
      }); 
    });
    

    Take a look at the fiddle: http://jsfiddle.net/74b5pkpv/

提交回复
热议问题