Jquery table things

From John Freier
Jump to: navigation, search

These are a bunch of different table manipulation things.


Add a new row to a table

 $('#tableId tr:last').after('<tr><td>item</td></tr>');


Remove all the rows of a table.

 $('#form-batch').each(function(){
    while($('tr', this).length>1){
       $('tbody tr:eq(1)', this).remove();
    }
 });


Clear the last column on all rows in a table

 $('#form-batch tr').each(function(){
    $(this).find('td:last').html("");
 });