n<a target=_blank href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css</a>
<span style="font-size:24px;">js:</span>
$(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();
} );
<span style="font-size:24px;">html:</span>引入:<a target=_blank href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css</a>
<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>
指定列:
var table = $('#example').DataTable();
table.row.add( {
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$3,120",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
} ).draw();