数据表不起作用(jQuery)

Ant*_*ast 3 html javascript datatable jquery

我制作了一个简单的表格来在DataTable中显示 dataTable 类似的内容。问题是我试图以类似的方式来做。

首先,我将代码放在下面:

<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>$320,800</td>
        </tr>
        <tr>
            <td>Cedric Kelly</td>
            <td>Senior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>$433,060</td>
        </tr>
        <tr>
            <td>Sonya Frost</td>
            <td>Software Engineer</td>
            <td>Edinburgh</td>
            <td>23</td>
            <td>$103,600</td>
        </tr>
     </tbody>
  </table>
Run Code Online (Sandbox Code Playgroud)

我不会忘记像这样调用函数:

<script type="text/javascript">
    $(document).ready(function(){
        $('#myTable').DataTable();
    });
</script>
Run Code Online (Sandbox Code Playgroud)

我还按照建议调用了外部资源,如下所示:

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="//cdn.datatables.net/1.10.4/js/jquery.data"></script>
Run Code Online (Sandbox Code Playgroud)

问题是它不能像这里所示那样工作。这是JSFIDDLE。任何想法?谢谢。

小智 5

检查这个链接演示这里你必须正确包含js

   <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>
Run Code Online (Sandbox Code Playgroud)