Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html table find row before last using jquery

Tags:

jquery

I have a standard HTML table.

Using jquery how do I find the row before the last row of the table ?

$('#table tr:last') will give me the last row, but how do I access the row that comes right before the last ?

Thanks

like image 888
G-Man Avatar asked Aug 19 '11 00:08

G-Man


1 Answers

$('#table tr').eq(-2)

or

$('#table tr:last').prev()

or

$('#table tr').eq($('#table tr').length - 2)

Demo for the three solutions.

like image 168
karim79 Avatar answered Oct 08 '22 13:10

karim79