[英]how to use jquery datatable plugin properly
以下是我的示例代码,但无法正常工作。 有人可以帮我如何使用这个jQuery数据表插件吗? 可以在sql结果字段表上使用此datatable插件吗? 谢谢
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
</head>
<body>
<table id="example" style="border:1px solid black;">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>etc</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
<td>etc</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
<td>etc</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
<td>etc</td>
</tr>
</tbody>
</table>
</body>
<script type="text/javascript">
$(document).ready(function () {
$('#example').dataTable();
});
</script>
</html>
从文档中: https : //datatables.net/manual/installation
为了使DataTables能够增强HTML表,该表必须是有效的,格式正确的HTML,并带有标头(thead)和正文(tbody)。 也可以使用可选的页脚(tfoot)。
尝试使用正确的列数将thead
添加到表中。
它看起来应该像这样,但是需要行和列,但是td
充满了内容。
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
<table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.