Adding a button to toolbar with jQuery DataTables
You can also use datatable button.js. Here is the source link:
https://datatables.net/extensions/buttons/examples/initialisation/custom.html
Don't forget to add below libraries (as mentioned in the above URL)
https://code.jquery.com/jquery-3.3.1.js
https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js
SOLUTION
Use the code below:
JavaScript:
var table = $('#example').DataTable({
// ... skipped ...
dom: 'l<"toolbar">frtip',
initComplete: function(){
$("div.toolbar")
.html('<button type="button" id="any_button">Click Me!</button>');
}
});
CSS:
.toolbar {
float:left;
}
DEMO
See this jsFiddle for code and demonstration.