-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.html
More file actions
executable file
·106 lines (96 loc) · 2.79 KB
/
tables.html
File metadata and controls
executable file
·106 lines (96 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--第一步:引入Javascript / CSS (CDN)-->
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
</head>
<body>
<!--第二步:添加如下 HTML 代码-->
<table id="table_id_example" class="display">
<thead>
<tr>
<th>name</th>
<th>position</th>
<th>salary</th>
<th>start_date</th>
<th>office</th>
<th>extn</th>
</tr>
</thead>
<tbody>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<th></th>
<th></th>
</tr>
</tbody>
</table>
</body>
<script type="text/javascript" charset="utf-8" async defer>
<!--第三步:初始化Datatables-->
$(document).ready( function () {
// var data = [
// [
// "Tiger Nixon",
// "System Architect",
// "Edinburgh",
// "5421",
// "2011/04/25",
// "$3,120"
// ],
// [
// "Garrett Winters",
// "Director",
// "Edinburgh",
// "8422",
// "2011/07/25",
// "$5,300"
// ]
// ];
// var data = [
// {
// "name": "Tiger Nixon",
// "position": "System Architect",
// "salary": "$3,120",
// "start_date": "2011/04/25",
// "office": "Edinburgh",
// "extn": "5421"
// },
// {
// "name": "Garrett Winters",
// "position": "Director",
// "salary": "$5,300",
// "start_date": "2011/07/25",
// "office": "Edinburgh",
// "extn": "8422"
// }
// ];
$('#table_id_example').DataTable({
data: data,
//使用对象数组,一定要配置columns,告诉 DataTables 每列对应的属性
//data 这里是固定不变的,name,position,salary,office 为你数据里对应的属性
// columns: [
// { data: 'name' },
// { data: 'position' },
// { data: 'salary' },
// { data: 'start_date' },
// { data: 'office' },
// { data: 'extn' }
// ]
});
} );
</script>
</html>