2017-02-20 214 views
2

這裏是我的截圖: enter image description hereJquery數據表按鈕不起作用?

這是我下面的代碼:

<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet"> 
<link href="https://cdn.datatables.net/buttons/1.2.4/css/buttons.dataTables.min.css" rel="stylesheet"> 


     <table id="example" class="display" cellspacing="0" width="100%"> 
     <thead> 
      <tr> 
       <th>Name</th> 
       <th>Position</th> 
       <th>Office</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td>Tiger Nixon</td> 
       <td>System Architect</td> 
       <td>Edinburgh</td> 

      </tr> 
      <tr> 
       <td>Garrett Winters</td> 
       <td>Accountant</td> 
       <td>Tokyo</td> 

      </tr> 
      </tbody> 
      </table> 

<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script 
<Script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script> 


<script> 
$(document).ready(function() { 
    $('#example').DataTable({ 
     dom: 'Bfrtip', 
     buttons: [ 
      { 
       text: 'My button', 
       action: function (e, dt, node, config) { 
        alert('Button activated'); 
       } 
      } 
     ] 
    }); 
}); 
</script> 

我試圖從https://datatables.net/extensions/buttons/custom使用此代碼。我不知道爲什麼my button按鈕沒有顯示出來。我想知道爲什麼這個代碼不工作。任何人都可以請告訴我如何使用'jQuery DataTables Button'?

回答

1
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> 
<script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script> 

你有腳本錯誤。試試這個。

截圖: http://prntscr.com/eazm0r

1

您沒有正確關閉script tag你有失蹤>從下面script tag

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>