有一个选择的分支,允许您为选择选项指定模板。https://github.com/thomasf1/chosen-with-templates
例如
<select data-placeholder="Choose your favorite candy..." class="chzn-select-template-example chzn-done" style="width: 350px; display: none;" tabindex="-1" id="sel4UA">
<option value=""></option>
<option data-type="chocolate" data-ico="http://cdn1.iconfinder.com/data/icons/winter_png/16/christmas_5.png" value="sel1">M&Ms</option>
<option data-type="fruity" data-ico="http://cdn1.iconfinder.com/data/icons/iconshock_vista_CharlieandtheChocolateFactory/png/24/CharlieandtheChocolateFactory1.png" value="sel2">Starburst</option>
<option data-type="fruity" data-ico="http://cdn1.iconfinder.com/data/icons/winter_png/16/christmas_5.png" value="sel3">Skittles</option>
<option data-type="chocolate" data-ico="http://cdn1.iconfinder.com/data/icons/fatcow/16/candy_cane.png" value="sel4">Reese's</option>
<option data-type="chocolate" data-ico="http://cdn1.iconfinder.com/data/icons/winter_png/16/christmas_5.png" value="sel5">Snickers</option>
</select>
脚本
$(".chzn-select-template-example").chosen({
template: function (text, value, templateData) {
return [
"<img src='" + templateData.ico + "' height='16' width='16'></img> " + text + "</i> value: " + value
].join("");
}
});