This is my following code:
JavaScript
x
49
49
1
<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet">
2
<link href="https://cdn.datatables.net/buttons/1.2.4/css/buttons.dataTables.min.css" rel="stylesheet">
3
4
5
<table id="example" class="display" cellspacing="0" width="100%">
6
<thead>
7
<tr>
8
<th>Name</th>
9
<th>Position</th>
10
<th>Office</th>
11
</tr>
12
</thead>
13
<tbody>
14
<tr>
15
<td>Tiger Nixon</td>
16
<td>System Architect</td>
17
<td>Edinburgh</td>
18
19
</tr>
20
<tr>
21
<td>Garrett Winters</td>
22
<td>Accountant</td>
23
<td>Tokyo</td>
24
25
</tr>
26
</tbody>
27
</table>
28
29
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
30
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script
31
<Script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script>
32
33
34
<script>
35
$(document).ready(function() {
36
$('#example').DataTable( {
37
dom: 'Bfrtip',
38
buttons: [
39
{
40
text: 'My button',
41
action: function ( e, dt, node, config ) {
42
alert( 'Button activated' );
43
}
44
}
45
]
46
} );
47
} );
48
</script>
49
I’m trying to use this code from https://datatables.net/extensions/buttons/custom. I dont why my button
button didn’t show up. I was wondering why this code is not working. Can anyone please tell me how to use ‘jQuery DataTables Button’?
Advertisement
Answer
JavaScript
1
3
1
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
2
<script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script>
3
you have script error. try this one.
Screenshot: http://prntscr.com/eazm0r