G-Man
G-Man

Reputation: 7241

html table find row before last using 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

Upvotes: 14

Views: 14621

Answers (1)

karim79
karim79

Reputation: 342645

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

or

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

or

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

Demo for the three solutions.

Upvotes: 29

Related Questions