Add table row in jQuery

前端 未结 30 2251
既然无缘
既然无缘 2020-11-21 05:40

What is the best method in jQuery to add an additional row to a table as the last row?

Is this acceptable?

$(\'#myTable\').append(\'

        
30条回答
  •  粉色の甜心
    2020-11-21 06:06

        // Create a row and append to table
        var row = $('', {})
            .appendTo("#table_id");
    
        // Add columns to the row.  properties can be given in the JSON
        $('', {
            'text': 'column1'
        }).appendTo(row);
    
        $('', {
            'text': 'column2',
            'style': 'min-width:100px;'
        }).appendTo(row);
    

提交回复
热议问题