【问题标题】:Can I add css syntax into "text" property on select2?我可以将 css 语法添加到 select2 的“文本”属性中吗?
【发布时间】:2016-08-13 04:32:30
【问题描述】:

我只想在 select2 上的“文本”上更改一些颜色,但它没有呈现。

results.push({
  id: item.kode_mobil,
  text: item.tipe_mobil + " (<span style='color:red'>"+item.nomor_polisi+"</span>)",
});

但结局是这样的

对不起我的英语。 谢谢

【问题讨论】:

  • 使用html 属性?
  • 什么是results?我们需要更多上下文。
  • 是的,我想。或者我该怎么办?
  • 我只想把一些文字染成红色@cambunctious 我应该把样式放在哪里?
  • 试试这个:results.push({ id: item.kode_mobil, text: item.tipe_mobil + item.nomor_polisi.fontcolor("red"), });

标签: javascript css json select2


【解决方案1】:

你可以添加css

假设你的选择标签类名是'.select'

然后

.select option
{
color:red
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多