2015-06-30 152 views
0

我有一個簡單的表,我想用數據表jquery插件來動態化它。Datatable插件不初始化

我不明白這是爲什麼不起作用:

http://jsfiddle.net/barnab21/hovcmaa8/

,因爲我的鏈接的可能?

<!-- DataTables CSS --> 
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css"> 

<!-- jQuery --> 
<script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script> 

<!-- DataTables --> 
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.js"></script> 

這裏我JS:

$(document).ready(function() { 
     $('#tableau_user').dataTable(); 
    }); 

回答

2

藉此jsfiddle.net

你的表是錯誤的,看看更新的表

<table id="tab_user" class="tableau_utilisateurs"> 
    <thead> 
     <tr> 
      <th>ID</th> 
      <th>Pseudonyme</th> 
      <th>Email</th> 
      <th>Date_inscription</th> 
      <th>Administrateur</th> 

     </tr> 
     </thead> 
     <tbody> 

     <tr> 
      <td>aaaaa</td> 
      <td>bbbbbb</td> 
      <td>ccccccc</td> 
      <td>ddddddd</td> 
      <td>eeeeee</td> 
     </tr> 
     </tbody> 
    </table> 
+1

更確切地說,他的表不一定是錯誤的,但DataTable插件需要'thead','tbody'(和'tfoot'如果需要)標籤才能工作。 – TheWanderingMind