Javascript 如何使用jQuery从表中的最后一个tr中选择上一个td?
我想从表中的最后一个tr中选择并更改以前的tds,但无法。如何使用jQuery实现这一点 选择上一个tr与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
$(".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