我正在尝试在我的项目中使用jQuery的Datatable JS,下载链接为这里。
我从同一来源下载了完整的库。包中提供的所有示例似乎都能正常工作,但当我尝试将它们合并到我的WebForms
中时,CSS和JS根本无法工作。
以下是我做的:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="myTable" class="display" cellspacing="0" 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>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<!-- table body -->
</tbody>
</table>
</div>
<script src="js/jquery.dataTables.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#myTable').DataTable();
});
</script>
</form>
</body>
</html>
我的解决方案中JS和CSS的文件结构如下:
我已按照手册添加了所有必要的JS和CSS引用。但是渲染效果并不如预期。没有CSS,甚至连JS也无法正常工作。
同时,在控制台中我收到以下错误信息:
ReferenceError: jQuery is not defined
TypeError: $(...).DataTable is not a function
我在这里仍然没有绑定任何动态数据(例如在重复器内),但它仍然无法工作。
请问有人可以指导我解决这个问题吗?