如何在 primefaces 中设置 selectOneMenu 的颜色?
<p:selectOneMenu id="col" value="#{projectsController.selected.listColor}">
<f:selectItem itemLabel="Activity" itemValue="1" class="redBackGroundColor"/>
<f:selectItem itemLabel="Activity1" itemValue="2" class="blueBackGroundColor"/>
<f:selectItem itemLabel="Activity2" itemValue="3" class="greenBackGroundColor"/>
</p:selectOneMenu>
这是我的CSS
.redBackGroundColor{
background-color:red;
}
(当然还有蓝色和绿色……) 但它不会影响 primeface 的行为。
最佳答案
在JSP中是不可能的 但你可以在 javascript 中做到这一点
例如:
$(this).children("tbody").children("tr").each(function () {
if ($(this).children("td").children("input").val() == 1) {
$(this).addClass("redBackGroundColor");
}
..... 这对我有用。
关于css - 如何将颜色设置为 f :selectItem in primefaces?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30169397/