简体   繁体   English

如何添加jQuery数据库插件?

[英]How to add jQuery database plugins?

I searched on DataTables and found some code to add dataTable but that is actually not working is their any different way to add JQuery Datatable Plugin? 我在DataTables上进行搜索,发现有一些代码可以添加dataTable但是实际上不起作用是他们添加JQuery Datatable插件的任何不同方法吗?

I added cdn as below inside head tag. 我在head标签下面添加了cdn如下。 My code is as follows: 我的代码如下:

<link rel="stylesheet" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"></script>

My table: 我的桌子:

<table id="example">
    <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>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
    </tbody>
</table>
                `

and jQuery: 和jQuery:

<script>
$(document).ready(function(){
    $('#example').DataTable();
});
</script>

you should add 您应该添加

https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js

instead you added css twice 相反,您两次添加了CSS

please read documentation 请阅读文档

In addition to the above code, the following Javascript library files are loaded for use in this example: 除了上面的代码之外,还加载了以下Javascript库文件以供本示例使用:

code.jquery.com/jquery-1.12.3.js code.jquery.com/jquery-1.12.3.js

https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js

 $(document).ready(function() { $('#example').DataTable(); }); 
 <link rel="stylesheet" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script src="http://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> <table id="example" class="display"> <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> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> </tbody> </table> 

<link rel="stylesheet" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

You have missed the datatable js file you need add it: 您错过了需要添加的datatable js文件:

<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM