Return to Snippet

Revision: 12607
at March 20, 2009 12:53 by 1man

Initial Code
Add a new table row to the bottom of the table

function addTableRow(jQtable){
        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 {

Initial URL

Initial Description
Great little snippit to add a <tr> 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!

Initial Title
Add table row to the bottom of a table

Initial Tags
table, DOM, jquery

Initial Language