[英]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.