jQuery 的插件 dataTables 是一个优秀的表格插件,提供了针对表格的排序、浏览器分页、服务器分页、筛选、格式化等功能。需要可以到 dataTables 的网站 http://www.datatables.net/ 下载这个脚本库。
在网页开发过程中,我们可能会从后台读入数据建表。当数据过大时,可能导致建表时间过长,于是就需要实现Ajax分页功能,代码如下:
HTML:
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Sala