jQuery Add Row to a Table

Sam Deering
Tweet

Simple jQuery code snippet to add a row to a table. It uses the :last selector to add the row at the end of the table using jQuery’s .after() function.

$('#myTable tr:last').after('<tr>...</tr>');

Also see: jQuery HTML Table Plugins

Free JavaScript: Novice to Ninja Sample

Get a free 32-page chapter of JavaScript: Novice to Ninja and receive updates on exclusive offers from SitePoint.