CSS选择器:选择TR,其中TD包含特殊值 [英] CSS Selector: Select TR where TD contains special value
本文介绍了CSS选择器:选择TR,其中TD包含特殊值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的表:
<table>
<tr>
<td>
row4545
</td>
</tr>
<tr>
<td>
row22
</td>
</tr>
<tr>
<td>
row6767
</td>
</tr>
</table>
我想在tr上设置背景颜色,其中包含td中的row22值。
可以用CSS以某种方式选择它。
I want to set a background-color on the tr which contains the value row22 in a td. Is it possible to select it somehow with CSS?
PS:我使用jQuery。
PS: I use jQuery.
推荐答案
尝试
$('tr td').filter(function(){
return $.trim($(this).text()) === "row22";
}).parent().css('background-color', 'blue')
演示:小提琴
这篇关于CSS选择器:选择TR,其中TD包含特殊值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文