DataTabless Add rows

参考官网案例:https://datatables.net/examples/api/add_row.html

JS:

$(document).ready(function() {

    var t = $('#example').DataTable();
    var counter = 1;
 
    $('#addRow').on( 'click'function () {
        t.row.add( [
            counter +'.1',
            counter +'.2',
            counter +'.3',
            counter +'.4',
            counter +'.5'
        ] ).draw( false );
 
        counter++;
    } );
 
    // Automatically add a first row of data
    $('#addRow').click();
 
HTML:
 
<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
                <th>Column 3</th>
                <th>Column 4</th>
                <th>Column 5</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
                <th>Column 3</th>
                <th>Column 4</th>
                <th>Column 5</th>
            </tr>
        </tfoot>
    </table>
 
 
CSS:
 
原文地址:https://www.cnblogs.com/sdream/p/5368267.html