使用JavaScript隐藏特定的HTML表格单元格

时间:2012-06-30 19:57:48

标签: javascript jquery html jquery-selectors

我找到了其他问题,通过这些问题我学会了如何隐藏第一行和第一行的第一行单元格;

$('table#truetable tr:first').hide();

$('table#truetable td:first').hide();

但是,如果我想使用这种方法隐藏第二行的第一个单元格呢?

3 个答案:

答案 0 :(得分:2)

$('table#truetable tr:eq(1) td:first-child').hide();

答案 1 :(得分:2)

$('#truetable tr:eq(1) td:first').hide();

:eq docs

jQuery(':eq(index)')
  

<强>索引
  要匹配的元素的从零开始的索引。

答案 2 :(得分:0)

这是一个css选择器:

:nth-child(N)

N是选择中孩子+1的索引