?如何使用Jquery选择除last之外的列单元格?

?如何使用Jquery选择除last之外的列单元格?,jquery,Jquery,我通过JSON呈现一个包含动态数据的表,我需要选择除最后一个单元格之外的所有单元格,因为我将进行一些计算。是否有任何选择器或函数可以解决此问题 HTML 您可以使用和选择器的组合 $tbody tr td:not:last-child.addClassbackground; .背景{ 边框:1px纯红; } + - + - + - 后果 + - 这是解决问题的代码 $("tbody tr td:nth-child(3)").filter("td:not(:last)").css("backgr

我通过JSON呈现一个包含动态数据的表,我需要选择除最后一个单元格之外的所有单元格,因为我将进行一些计算。是否有任何选择器或函数可以解决此问题

HTML


您可以使用和选择器的组合

$tbody tr td:not:last-child.addClassbackground; .背景{ 边框:1px纯红; } + - + - + - 后果 + -
这是解决问题的代码

$("tbody tr td:nth-child(3)").filter("td:not(:last)").css("background", "CornflowerBlue")

1将包含按钮的类添加到。2选择除最后一个之外的所有td元素,使用步骤1中的“不与类配对”嘿,satpal,我需要选择3列并在最后一个单元格上动态显示结果,这就是为什么我使用N-child3,但使用该代码我也选择了最后一个,我不想选择最后一个,因为在最后一个单元格中我会显示结果
$("tbody tr td:nth-child(3)").filter("td:not(:last)").css("background", "CornflowerBlue")
$("tbody tr td:not(:last-child)").addClass("background");
$("tbody tr td:nth-child(3)").filter("td:not(:last)").css("background", "CornflowerBlue")