Is it possible to display html content inside a jquery chosen plugin option?

StackOverflow https://stackoverflow.com/questions/21941516

  •  14-10-2022
  •  | 
  •  

Вопрос

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