Difference between revisions of "Jquery table things"

From John Freier
Jump to: navigation, search
(Created page with '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. …')
 
Line 12: Line 12:
 
     }
 
     }
 
   });
 
   });
 +
 +
 +
Clear the last column on all rows in a table
 +
$('#form-batch tr').each(function(){
 +
    $(this).find('td:last').html("");
 +
});

Revision as of 13:31, 22 September 2011

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("");

});