mardi 7 février 2017

Selector for siblings of a specific element that match a condition

Vote count: 0

I have the following scenario:

<table>
  <tr class="header">
  <tr class="data1">
  <tr class="data2">
  <tr class="data3">
  <tr class="header">
  <tr class="data1">
  <tr class="data2">
</table>

I want to change the text color of the data elements under the first header to blue, and the data elements under the second header to red.

I've tried various nth-child and adjacent sibling (+) but all my tries are incomplete.

tr[class^=data] gets all of elements I want to affect, but I need them in two groups.

I don't know how many data elements I will have, I do know I have only 2 header

I can't use javascript/jquery here, just selectors

asked 25 secs ago

Let's block ads! (Why?)



Selector for siblings of a specific element that match a condition

Aucun commentaire:

Enregistrer un commentaire