jQuery和Table,获取NTH列中的每个单元格 [英] jQuery and Table, grab every cell in the NTH column
本文介绍了jQuery和Table,获取NTH列中的每个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说一下您的基本表格布局(如下所示).如何抓取每个NTH单元?我基本上想在N列的单元格中添加一个CSS类.
Lets say I have your basic table layout (like below). How to I grab every NTH cell? I basically want to add a css class to the cells in column N.
因此,如果我想要第2列中的所有单元格,我希望有一个jQuery obj,其中包含以下已标记的单元格:
So if I wanted all cells in column 2, I want to have a jQuery obj that contain the following cells that are marked:
<table>
<tr class="trow">
<td></td>
<td></td> <!-- included -->
<td></td>
</tr>
<tr class="trow">
<td></td>
<td></td> <!-- included -->
<td></td>
</tr>
<tr class="trow">
<td></td>
<td></td> <!-- included -->
<td></td>
</tr>
</table>
推荐答案
尝试 jQuery nth Cell选择器 ...必须在那里!
Try the jQuery nth Cell selector... Must be there!
$("table tr td:nth-child(n)").addClass("MyGreatClass");
这篇关于jQuery和Table,获取NTH列中的每个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文