jquery: using appendTo in second to last row of table

Viewed 40577

I have a piece of the DOM that I'd like to insert into my page. Currently I'm just blindly using:

$(myblob).appendTo(someotherblob);

How do I do the same thing, but append myblob to the second to last row that is within someotherblob. someotherblob in this case is a table and I want to inject a row above the second to last one.

9 Answers

As simple as this:

$("#TableName tr:last").prev().before("<tr><td>Hello World</td></tr>");
Related