元素的条件样式[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

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

enter image description here

有没有办法在css中应用条件样式?我无法更改html或更改它。

这是css代码:

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

提前致谢

css
1个回答
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为这些行添加颜色:-)

© www.soinside.com 2019 - 2024. All rights reserved.