I have the following jQuery that I m trying to use to change the background colour of a column where its header has a class.
So for example:
$( th ).each(function (i) {
if ($(this).hasClass( headerSortUp ) || $(this).hasClass( headerSortDown )) {
sortIndex = $(this).index();
}
$( tr ).each(function () {
$( td:eq( + sortIndex + ) ).css( background-color , orange );
});
});
因此,如果我有这样一个表格:
<table>
<tr>
<th class="headerSortDown">Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
</tr>
</table>
因此,在这一例子中,整个第一栏应当有一 b。 但是,它没有工作...... 我已经做过错的任何想法? 增 编