官方网站已经提到(在“手动检查或取消选中复选框?”部分)只是为了使用 click()
例如
$("#ddl_singleSelect")
.multiselect("widget")
.find(":radio[value='']").click(); // change displayed selectedText
$("#ddl_singleSelect option[value='']")
.prop("selected", true) // change val()
.trigger("change"); // fire change event
$("#ddl_multiselect").multiselect("uncheckAll"); // init by de-selecting all
$("#ddl_multiselect")
.multiselect("widget")
.find( ":checkbox[value='1']"
+ ",:checkbox[value='2']"
+ ",:checkbox[value='3']"
+ ",:checkbox[value='4']"
).click(); // change displayed selecetdText
$("#ddl_multiselect")
.find( "option[value='1']"
+ ",option[value='2']"
+ ",option[value='3']"
+ ",option[value='4']"
).prop("selected", true); // change val()
$("#ddl_multiselect").trigger("change"); // fire change event
或通过HTML
<select name="example-presets" multiple="multiple" size="5">
<option value="option1" selected="selected">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3" selected="selected">Option 3</option>
<option value="option4" selected="selected">Option 4</option>
<option value="option5" disabled="disabled">Option 5</option>
<option value="option6" disabled="disabled">Option 6</option>
<option value="option7">Option 7</option>
<option value="option8">Option 8</option>
<option value="option9">Option 9</option>
</select>
....
<script type="text/javascript">$("select").multiselect();</script>