/ Published in: jQuery
                    
                                        
Great little snippit to add a  to the bottom of a table. Note the use of the context in the jQuery e.g var n = $('tr:last td', this).length; Will have to use this in the future, very good to know!
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/*
Add a new table row to the bottom of the table
*/
function addTableRow(jQtable){
jQtable.each(function(){
var $table = $(this);
// Number of td's in the last table row
var n = $('tr:last td', this).length;
var tds = '<tr>';
for(var i = 0; i < n; i++){
tds += '<td> </td>';
}
tds += '</tr>';
if($('tbody', this).length > 0){
$('tbody', this).append(tds);
}else {
$(this).append(tds);
}
});
}
URL: http://jquery-howto.blogspot.com/2009/02/add-table-row-using-jquery-and.html
Comments
 Subscribe to comments
                    Subscribe to comments
                
                