是否可以在选定的选项中添加任何html元素,如<p><strong>
或其他任何内容?
var chzn = $('#chzn');
chzn.chosen({width:'125'});
//
chzn
.append($('<option>', {
value: 1,
text : 'title: <strong> description </strong>'
}))
chzn
.val('')
.trigger("chosen:updated")
答案 0 :(得分:3)
你可以这样做:
html : 'title: <strong> description </strong>'
答案 1 :(得分:0)
或者,你可以这样做:
var $strongOptions = chzn.parent().find("li.search-choice span:contains('<strong>')");
$strongOptions.each(function () {
var content = $(this).text();
$(this).html($.parseHTML(content));
});