引入 <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
<script src="js/plugins/chosen/chosen.jquery.js"></script>
在js文件中加入:
var config = {
'.chosen-select': {},
'.chosen-select-deselect': {
allow_single_deselect: true
},
'.chosen-select-no-single': {
disable_search_threshold: 10
},
'.chosen-select-no-results': {
no_results_text: 'Oops, nothing found!'
},
'.chosen-select-width': {
width: "95%"
}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
<div class="form-group">
<label class="font-noraml">多选</label><div class="input-group">
<select data-placeholder="选择省份" class="chosen-select" multiple style="width:350px;" tabindex="4">
<option value="">请选择省份</option>
<option value="110000" hassubinfo="true">北京</option>
<option value="120000" hassubinfo="true">天津</option>
<option value="130000" hassubinfo="true">河北省</option>
<option value="140000" hassubinfo="true">山西省</option>
<option value="150000" hassubinfo="true">内蒙古自治区</option>
<option value="210000" hassubinfo="true">辽宁省</option>
<option value="220000" hassubinfo="true">吉林省</option>
<option value="230000" hassubinfo="true">黑龙江省</option>
<option value="310000" hassubinfo="true">上海</option>
<option value="320000" hassubinfo="true">江苏省</option>
<option value="330000" hassubinfo="true">浙江省</option>
<option value="340000" hassubinfo="true">安徽省</option>
<option value="350000" hassubinfo="true">福建省</option>
<option value="360000" hassubinfo="true">江西省</option>
<option value="370000" hassubinfo="true">山东省</option>
<option value="410000" hassubinfo="true">河南省</option>
<option value="420000" hassubinfo="true">湖北省</option>
<option value="430000" hassubinfo="true">湖南省</option>
<option value="440000" hassubinfo="true">广东省</option>
<option value="450000" hassubinfo="true">广西壮族自治区</option>
<option value="460000" hassubinfo="true">海南省</option>
<option value="500000" hassubinfo="true">重庆</option>
<option value="510000" hassubinfo="true">四川省</option>
<option value="520000" hassubinfo="true">贵州省</option>
<option value="530000" hassubinfo="true">云南省</option>
<option value="540000" hassubinfo="true">西藏自治区</option>
<option value="610000" hassubinfo="true">陕西省</option>
<option value="620000" hassubinfo="true">甘肃省</option>
<option value="630000" hassubinfo="true">青海省</option>
<option value="640000" hassubinfo="true">宁夏回族自治区</option>
<option value="650000" hassubinfo="true">新疆维吾尔自治区</option>
<option value="710000" hassubinfo="true">台湾省</option>
<option value="810000" hassubinfo="true">香港特别行政区</option>
<option value="820000" hassubinfo="true">澳门特别行政区</option>
<option value="990000" hassubinfo="true">海外</option>
</select>
</div>
</div>