【发布时间】:2018-09-18 06:27:04
【问题描述】:
我有一个 php 文件,它使用数据库中的值创建一个表。
这是打印出来的 HTML:
<table id="table" class="display dataTable no-footer">
<thead>
<tr class="headContainer">
<th colspan="1">
<div id="tablePerPage"></div>
</th>
<th colspan="1">
<div id="tableSearch"></div>
</th>
</tr>
<tr>
<th colspan="2" class="rowHeader">
Locations
</th>
</tr>
</thead>
<tbody id="tableContent">
<tr class="tableRow">
<td>
<a href="q=NewYork">New York</a>
</td>
</tr>
</tbody>
</table>
这里是JS代码:
$('#table').DataTable({
autoWidth: true
responsive: true,
lengthChange: true,
ordering: true
});
$('#tableSearch').html($('.dataTables_filter'));
$('#tablePerPage').html($('#table_length'));
headers 是不变的,但是 body 数据是动态变化的。
如何解决这个问题?
【问题讨论】:
标签: javascript jquery html datatable