我正在尝试使用 Chosen plugin 我正在使用 select 元素选项。
我用它来按国家名称显示时区名称。 国家名称作为选项组标签和时区名称作为选项
我的问题:
- 如何使搜索也适用于 optgroup 标签(而不仅仅是选项)
- 如何更改选项的悬停背景颜色?
谢谢。
最佳答案
您可以更新 chosen.css 中突出显示的类,如下所示:
.chosen-container .chosen-results li.highlighted {
background-color: #F26655;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #F26655), color-stop(90%, #2a62bc));
background-image: -webkit-linear-gradient(#F26655 20%, #F26655 90%);
background-image: -moz-linear-gradient(#F26655 20%, #F26655 90%);
background-image: -o-linear-gradient(#F26655 20%, #F26655 90%);
background-image: linear-gradient(#F26655 20%, #F26655 90%);
color: #fff;
}
在我的版本中,此类位于第 174 行。 例如,#F26655 是您想要的颜色。
关于jQuery Chosen 插件定制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14619332/