Jquery 隐藏所有';这不是TR的第一个TD。

Jquery 隐藏所有';这不是TR的第一个TD。,jquery,html,Jquery,Html,我试图将每个TD隐藏在不是第一个TD的每个TR中。你可以看到我的一些尝试,但我在这方面运气不好 $(文档).ready(函数(){ $(“tr”)。每个(功能){ $(“td”).not(“:first”).hide(); //$(this.next('td:second').hide(); //$(this.next('td')。而不是(“:first”).hide(); }) });试试看 仅隐藏第一个td $("tr").find('td:eq(0)').hide(); -->从0

我试图将每个TD隐藏在不是第一个TD的每个TR中。你可以看到我的一些尝试,但我在这方面运气不好

$(文档).ready(函数(){
$(“tr”)。每个(功能){
$(“td”).not(“:first”).hide();
//$(this.next('td:second').hide();
//$(this.next('td')。而不是(“:first”).hide();
})
});

试试看

仅隐藏第一个
td

$("tr").find('td:eq(0)').hide();


-->从
0
索引开始

隐藏除第一个td之外的所有td

$("tr").find('td:not(:eq(0))').hide();
试试这个:

$(document).ready(function () {
  $("td:nth-child(n+2)").hide()
});

不要使用
:首先使用

或者,您可以使用纯CSS来实现这一点(除非您有特殊的理由为此使用jQuery):


这不是TDHad第一次将其更改为(1),但它现在可以工作了
这只会隐藏第二个TD?如果他们想隐藏第一个TD,OP应该重写这个问题,因为当前的编写方式是隐藏除第一个之外的所有TD。@Branndon很高兴这有帮助:)
$(document).ready(function () {
   $("tr").each(function () { 
     $("td").not(":first-of-type").hide();
  })
});
.table td:not(:first-of-type) { display: none }