2013-05-28 52 views
0

我想選擇和更改表中最後一個tr的前一個tds,但我不能。如何使用jquery執行此操作?如何使用jquery從表格中最後一個tr選擇前一個td?

enter image description here

選擇一個先前TR與;

$(".tbl tr:last-child").prev() 

但是我怎樣才能選擇prev tr的孩子?

http://jsfiddle.net/dba7v/1/

+0

要選擇從第二所有細胞最後一排? –

+0

你已經得到了你的答案,但是,我認爲你可以學習這個問題的** main **課程是['.find()'](http://api.jquery.com/find/)方法jQuery的。這很有用,例如你的情況:'$(「。tbl tr:last-child」)。prev()。find('td')',就像'$'用法,但它會搜索當前匹配的集合,而不是整個文檔。 – 2013-05-28 14:46:49

+0

謝謝你的建議@NOX – midstack

回答

4

$(".tbl tr:last-child").prev().children()

或簡單$(".tbl tr:nth-last-child(2) > td")

相關問題