Javascript 数据表不起作用(jQuery)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27873581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DataTable doesn't work (jQuery)
提问by Anthosiast
I have made a simple table to show dataTable something like this in DataTable. The problem is I have tried to do in a similar way like it does.
我制作了一个简单的表格来在DataTable 中显示类似这样的 dataTable 。问题是我试图以类似的方式做。
First of all, I have put the coding below:
首先,我把编码放在下面:
<table id="myTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>0,800</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>3,060</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>3,600</td>
</tr>
</tbody>
</table>
I don't forget to call function something like this:
我不会忘记像这样调用函数:
<script type="text/javascript">
$(document).ready(function(){
$('#myTable').DataTable();
});
</script>
And also I have call external sources as suggested like this:
而且我也按照这样的建议调用了外部资源:
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//cdn.datatables.net/1.10.4/js/jquery.data"></script>
The problem is it doesnt work as shown as here.Here is JSFIDDLE. Any idea? Thanks.
回答by
Check this link Demo hereyou must include the js correctly
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>
回答by Jeremy Thompson
I spent hours working this out, turns out I was missing tags needed for the Search to work:
我花了几个小时来解决这个问题,结果我缺少搜索工作所需的标签:
<thead></thead>
and the
和
<tbody></tbody>
回答by Hamza Khan
Remove // from the beginning of links. And include https://before these links. i also faced this issue. But now its working.
从链接的开头删除 //。并在这些链接之前包含https://。我也遇到过这个问题。但现在它的工作。

