// 引入 DataTables 库
// <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.css">
// <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
// <script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.js"></script>
$(document).ready(function() {
// 初始化 DataTable
$('#example').DataTable();
} );
// HTML 部分
// <table id="example" class="display" style="width:100%">
// <thead>
// <tr>
// <th>Name</th>
// <th>Position</th>
// <th>Office</th>
// <th>Age</th>
// <th>Start date</th>
// <th>Salary</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>Tiger Nixon</td>
// <td>System Architect</td>
// <td>Edinburgh</td>
// <td>61</td>
// <td>2011/04/25</td>
// <td>$320,800</td>
// </tr>
// <!-- 更多行数据 -->
// </tbody>
// <tfoot>
// <tr>
// <th>Name</th>
// <th>Position</th>
// <th>Office</th>
// <th>Age</th>
// <th>Start date</th>
// <th>Salary</th>
// </tr>
// </tfoot>
// </table>
$(document).ready 函数中,使用 $('#example').DataTable(); 来初始化表格。#example 是表格的 ID。<thead>、<tbody> 和 <tfoot> 部分。表格的内容可以动态生成或静态定义。这样,一个简单的 DataTable 就创建好了,具备分页、排序和搜索功能。
上一篇:js md5加密
下一篇:js split 多个分隔符
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站