参考官网案例: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:
 

相关文章:

  • 2022-01-15
  • 2021-08-01
  • 2021-09-20
  • 2021-09-30
  • 2021-06-20
  • 2021-07-29
  • 2021-12-01
猜你喜欢
  • 2021-05-19
  • 2021-06-22
  • 2022-12-23
  • 2021-07-18
  • 2021-07-11
  • 2021-10-11
  • 2021-10-02
相关资源
相似解决方案