图一
去除部分
图二
修改后
第一步
引入datatable的相关js,css
//css
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
//js
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
第二步
引入按钮功能相关js,css
//css
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
//js
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
ps:添加特殊按钮功能请去官网引入相关js与css
datatable官网参考页https://datatables.net/download/release
第三步
html代码
//css
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th></th>
<th >Name</th>
<th>Position</th>
<th>Office</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<th></th>
<th>Tiger Nixon</th>
<th>System Architect</th>
<th>Edinburgh</th>
<th>$320,800</th>
</tr>
<tr>
<th></th>
<th>Tiger Nixon2</th>
<th>System Architect</th>
<th>Edinburgh</th>
<th>$320,800</th>
</tr>
</tbody>
</table>
js代码
//css
$(document).ready(function(){
var table = $('#example').DataTable( {
dom: '<"pull-left"B>ft<"pull-left"i>p',
buttons: [
{
text: '<span class="glyphicon glyphicon-save" title="导出"><font>导出</font></span>',
extend: 'csv'
},
'copy',
],
} );
创建成功