元素的条件样式

时间:2018-11-12 16:33:36

标签: css

我正在尝试将样式应用于特定元素,即。优先级为1的元素应为红色,优先级3为绿色

enter image description here

我有办法在CSS中应用条件样式吗?我无法更改html或对其进行更改。

这是CSS代码:

.priorityDerived_shortCodeCell{
background: none repeat scroll 0 0 #EC1818 !important;
}

预先感谢

1 个答案:

答案 0 :(得分:0)

通常您可以使用此:

<style>.red { color: red; }</style>
<table>
    <tr>
        <td>PRIORITY1</td>
        <td>PRIORITY2</td>
        <td>PRIORITY3</td>
        <td>PRIORITY1</td>
    </tr>
</table>
<script>$('td:contains("PRIORITY1")').addClass("red");</script>

由于您无法控制HTML文件或服务程序,因此,极少数解决方案之一是将插件编程为Chrome并让Chrome为行涂色:-)