Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jQuery从表中的最后一个tr中选择上一个td?_Javascript_Jquery_Css_Html Table - Fatal编程技术网

Javascript 如何使用jQuery从表中的最后一个tr中选择上一个td?

Javascript 如何使用jQuery从表中的最后一个tr中选择上一个td?,javascript,jquery,css,html-table,Javascript,Jquery,Css,Html Table,我想从表中的最后一个tr中选择并更改以前的tds,但无法。如何使用jQuery实现这一点 选择上一个tr与 $(".tbl tr:last-child").prev() 但如何选择上一个tr的孩子 $(“.tbl tr:last child”).prev().children() 或者简单的$(“.tbl tr:nth last child(2)>td”)$(“.tbl tr:last child”).prev().children() 或者简单的$(“.tbl tr:nth last ch

我想从表中的最后一个tr中选择并更改以前的tds,但无法。如何使用jQuery实现这一点

选择上一个tr与

$(".tbl tr:last-child").prev()
但如何选择上一个tr的孩子

$(“.tbl tr:last child”).prev().children()

或者简单的
$(“.tbl tr:nth last child(2)>td”)
$(“.tbl tr:last child”).prev().children()


或者简单的
$(“.tbl tr:nth last child(2)>td”)

您想选择从第二行到最后一行的所有单元格吗?您得到了答案,但是,我认为您可以从这个问题中学到的主要教训是jQuery中的方法。它非常有用,例如,在您的示例中:
$(“.tbl tr:last child”).prev().find('td')
,它类似于
$
用法,但它将搜索当前匹配集,而不是整个文档。感谢您的建议@nox您想选择从第二行到最后一行的所有单元格吗?您得到了答案,但是,我认为您可以从这个问题中学到的主要教训是jQuery中的方法。它非常有用,例如在您的示例中:
$(“.tbl tr:last child”).prev().find('td')
,它类似于
$
用法,但它将在当前匹配集中搜索,而不是整个文档。感谢您的建议@NOX