twitter-bootstrap 更改 bootstrap-select (selectpicker) 的选定选项颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38831175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 00:11:55  来源:igfitidea点击:

Change selected option color of bootstrap-select (selectpicker)

htmlcsstwitter-bootstrap

提问by CostCare

I can't get the color of the selected option in a bootstrap-selectto change.. I think this is something real simple, but I tried different things but I can't get it to change.

我无法在 abootstrap-select中更改所选选项的颜色。我认为这很简单,但我尝试了不同的方法,但无法更改。

采纳答案by Szymon

select option[selected]{
    background-color: xxx
}

回答by Nick Bull

If you just want the selected options value where the options are words for colours:

如果您只想要选择的选项值,其中选项是颜色词:

$("select option:selected").val();

To get the selected options background colour:

要获取所选选项的背景颜色:

$("select option:selected").css('backgroundColor');

EDITper comment:

编辑每个评论:

$("select option:selected").css('backgroundColor', '#FFFFFF');