我有一个这样的表:
<table>
<tr>
<td>
row4545
</td>
</tr>
<tr>
<td>
row22
</td>
</tr>
<tr>
<td>
row6767
</td>
</tr>
</table>
我想在 tr 上设置一个背景色,它在 td 中包含值 row22。 是否可以用 CSS 以某种方式选择它?
PS:我使用 jQuery。
最佳答案
尝试
$('tr td').filter(function(){
return $.trim($(this).text()) === "row22";
}).parent().css('background-color', 'blue')
演示:Fiddle
关于jquery - CSS 选择器 : Select TR where TD contains special value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17188896/