Я вижу это сообщение на , выделяя четные столбцы , но могу ли я выделить только выбранные столбцы?
Вот код, который они используют:
$("table.Table22 > tbody > tr > td:nth-child(even)").css("background","blue");
Но мне бы хотелось: ПРИМЕЧАНИЕ: class="highlight"
будет в выбранных столбцах, поэтому, если я выберу столбец 3, class="highlight"
будет удален из столбца 2 и добавлен в столбец 3. jQuery необходимо добавить класс на основе в выбранном столбце.
<table class="tbl">
<tr>
<th class="firstColumn">
Cell 1:Heading
</th>
<th class="highlight">
Selected column so this should be highlighted
</th>
<th>
Cell 3:Heading
</th>
<th>
Cell 4:Heading
</th>
<th>
Cell 5:Heading
</th>
</tr>
<tr>
<td>
Cell 1:Row 1
</td>
<td class="highlight">
Selected column so this should be highlighted
</td>
<td>
Cell 3:Row 1
</td>
<td>
Cell 4:Row 1
</td>
<td>
Cell 5:Row 1
</td>
</tr>
<tr>
<td>
Cell 1:Row 2
</td>
<td class="highlight">
Selected column so this should be highlighted
</td>
<td>
Cell 3:Row 2
</td>
<td>
Cell 4:Row 2
</td>
<td>
Cell 5:Row 2
</td>
</tr>
</table>