基于jQuery UI的多项选择下拉列表框组件 jQuery UI MultiSelect Widget

Displaying options in a list

Using the selectedList Parameter

The selectedList parameter is a boolean/numeric value denoting whether or not to display the checked opens in a list, and how many. A number greater than 0 denotes the maximum number of list items to display before switching over to the selectedText parameter.

$("select").multiselect({
   selectedList: 4 // 0-based index
});

Passing a Function to selectedText

Passing a function to the selectedText option gives you low-level control of what the widget displays. The function receives three arguments: the number of checkboxes checked, the total number of checkboxes, and an array of the checkboxes (DOM elements) that were checked. Example usage:

$("select").multiselect({
   selectedText: function(numChecked, numTotal, checkedItems){
      return numChecked + ' of ' + numTotal + ' checked';
   }
});

The selectedList option is simply a convenience method for the selectedText option.