MultiSelect是一个jQuery插件,它将普通的多选列表转换为带有复选框的多列下拉列表。
# NPM $ npm install jQuery-MultiSelect --save # Bower $ bower install jQuery-MultiSelect
1.在html页面中包含jQuery库和jQuery多选插件的文件。
<script src="jquery.min.js"></script> <script src="jquery.multiselect.js"></script>
2.调用上的插件倍数
选择元素。
$('select[multiple]').multiselect({ /* OPTIONS */ });
3.可用选项。
$('select[multiple]').multiselect({ columns: 1, // how many columns should be use to show options search : false, // include option search box // search filter options searchOptions : { delay : 250, // time (in ms) between keystrokes until search happens showOptGroups: false, // show option group titles if no options remaining searchText : true, // search within the text searchValue : false, // search within the value onSearch : function( element ){} // fires on keyup before search on options happens }, // plugin texts texts: { placeholder : 'Select options', // text to use in dummy input search : 'Search', // search input placeholder text selectedOptions: ' selected', // selected suffix text selectAll : 'Select all', // select all text unselectAll : 'Unselect all', // unselect all text noneSelected : 'None Selected' // None selected text }, // general options selectAll : false, // add select all option selectGroup : false, // select entire optgroup minHeight : 200, // minimum height of option overlay maxHeight : null, // maximum height of option overlay maxWidth : null, // maximum width of option overlay (or selector) maxPlaceholderWidth: null, // maximum width of placeholder button maxPlaceholderOpts : 10, // maximum number of placeholder options to show until "# selected" shown instead showCheckbox : true, // display the checkbox to the user optionAttributes : [], // attributes to copy to the checkbox from the option element // Callbacks onLoad : function( element ){}, // fires at end of list initialization onOptionClick : function( element, option ){}, // fires when an option is clicked onControlOpen : function( element ){}, // fires when the options list is opened onControlClose: function( element ){}, // fires when the options list is closed onSelectAll : function( element, selected ){}, // fires when (un)select all is clicked onPlaceholder : function( element, placeholder, selectedOpts ){}, // fires when the placeholder txt is updated // @NOTE: these are for future development minSelect: false, // minimum number of items that can be selected maxSelect: false, // maximum number of items that can be selected });
4.API方法。
// loadOptions( options, overwrite, updateSelect ) $('select[multiple]').multiselect( 'loadOptions', [{ name : 'Option Name 1', value : 'option-value-1', checked: false },{ name : 'Option Name 2', value : 'option-value-2', checked: false }]); // updates settings $('select[multiple]').multiselect( 'settings', { columns: 2 }); // disables the plugin $('select[multiple]').multiselect( 'unload' ); // reloads the plugin $('select[multiple]').multiselect( 'reload' ); // resets the plugin $('select[multiple]').multiselect( 'reset' ); // enables/disables $('select[multiple]').multiselect( 'disable', true ); $('select[multiple]').multiselect( 'disable', false );
v2.4.22 (2023-03-03)
v2.4.21版本(2022-03-16)
v2.4.20 (2021-12-08)
v2.4.19版本(2020-06-27)
v2.4.18版本(2020-01-29)
v2.4.17版本(2019-10-16)
v2.4.16版本(2019-01-19)
v2.4.15(2018年8月18日)
v2.4.14版本(2018-07-18)
v2.4.13版本(2018-07-08)
v2.4.12(2018年5月23日)
v2.4.11(2018年03月07日)
v2.4.10(2018年2月17日)
v2.4.9版本(2018-01-19)
v2.4.8版本(2018年01月09日)
v2.4.7版本(2017-12-01)
v2.4.6版本(2017-11-10)
v2.4.5版本(2017-11-08)
v2.4.4版本(2017-11-01)
2017-10-14
2017-09-08
2017-08-05
2017-07-22
2017-06-17
2017-06-03
2016-03-11
2016-01-15
2015-12-11
2015-11-20
2015-11-19
2015-06-12
2015-06-11
2015-06-10