My table looks like so:
I wrote a bit of CSS so when I hover on a specific field under a 15-year mortgage column, the corresponding cell under the 30-year mortgage is also hovered.
td:hover, td:hover + td + td + td + td {
background-color: grey;
}
This works great when I select a 15-year mortgage field, but not when I select a 30-year mortgage field. That is, it doesn't work in the other direction.
The table structure is pretty straightforward:
<thead>
<tr>
<th colSpan='1' />
<th colSpan='4'>15 year</th>
<th colSpan='4'>30 year</th>
</tr>
<tr>
<th colSpan='1' />
<th>Mortgage Payment</th>
<th>Investment Payment</th>
<th>Loan Amount</th>
<th>Investment Amount</th>
<th>Mortgage Payment</th>
<th>Investment Payment</th>
<th>Loan Amount</th>
<th>Investment Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Year x</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
...
</tbody>
I've already read that there is no "previous sibling" selector in CSS so I am looking for a different solution. JavaScript solutions are fine if pure CSS can't get the job done.