質問

Is it possible to add any html element just like <p><strong> or any other inside a chosen select option?

var chzn = $('#chzn');
chzn.chosen({width:'125'});

//
chzn
    .append($('<option>', {
        value: 1,
        text : 'title: <strong> description </strong>'
    }))


chzn
    .val('')
    .trigger("chosen:updated")

http://jsfiddle.net/Xs3wQ/

役に立ちましたか?

解決

you can do this:

html : 'title: <strong> description </strong>'

他のヒント

Alternatively, you can do this:

var $strongOptions = chzn.parent().find("li.search-choice span:contains('<strong>')");

$strongOptions.each(function () {
                var content = $(this).text();
                $(this).html($.parseHTML(content));
            });
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top