Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table id="dataTable">
- <thead>
- <tr>
- <th>座號</th>
- <th>姓名</th>
- <th>性別</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
- <script>
- var table = $("#dataTable").DataTable();
- var students = [
- { id: 1, name: "Justin", gender: "男" },
- { id: 2, name: "Kevin", gender: "男" },
- { id: 3, name: "Karen", gender: "女" },
- { id: 4, name: "Lucy", gender: "女" },
- ];
- students.forEach(function (element) {
- table.row.add([
- element.id,
- element.name,
- element.gender
- ]);
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement