How to change background color of nth-last-child(2) when :last-child is style is color: yellow

18 Views Asked by At

I need when last child's color is yellow need to add :nth-last-child(2) as RED background color without JavaScript

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}
tr th[style='color: yellow;']:nth-child(2) {
  background-color: red;
}
<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th class="last" style="color: yellow;">Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
</table>

0

There are 0 best solutions below