jQuery:如何选择除每行中最后一个表格中的每个单元格?

cle*_*tus 7 javascript jquery

我希望每行中的每个单元格除了每行中的最后一行.我试过了:

$("table tr td:not(:last)")
Run Code Online (Sandbox Code Playgroud)

但这似乎给了我除了表中最后一个细胞以外的所有细胞.不是我想要的.

我确信这很简单,但我仍然围绕着选择器.

Ric*_*ega 24

尝试:

$('table tr td:not(:last-child)')
Run Code Online (Sandbox Code Playgroud)


mip*_*ipi 7

你可以试试

$("table td:not(:last-child)")
Run Code Online (Sandbox Code Playgroud)

要么

$("table td:not(:nth-child(n))")
Run Code Online (Sandbox Code Playgroud)

其中n是子元素的从1开始的索引

要么

$("table td").not(":last-child")
Run Code Online (Sandbox Code Playgroud)