CSS Selector: Select TR where TD contains special value
问题 I have a Table like this: <table> <tr> <td> row4545 </td> </tr> <tr> <td> row22 </td> </tr> <tr> <td> row6767 </td> </tr> </table> 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: I use jQuery. 回答1: Try $('tr td').filter(function(){ return $.trim($(this).text()) === "row22"; }).parent().css('background-color', 'blue') Demo: Fiddle 回答2: $('td').filter(function(){ return $.trim($(this).text()) === "row22"; })