How to use custom button to toggle between Datatable
How to use custom button to toggle between Datatable

I am using the custom button to to display a datatable as shown below. How can I use the same button to toggle between this datatable.
For example when I click the button first time, it shows the table, how can I make it hide/destroy when clicking second time?
Thank you
{
text: 'Invoice Details',
action: function ( e, dt, node, config ) {
$('#testfour').show();
var tabledetails = $('#testfour').DataTable( {
"processing": true,
"serverSide": true,
"dom": 'lBrtip',
"ajax":
{
url:"/xxx.php",
type:'POST',
"data": function ( d ) {
var agreementID = abc;
d.agreementID = agreementID;
console.log(d.agreementID);
}
},
"columns": [
{ data: "agreement_id_fk" },
.....
....
],
});
}
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use jQuery toggle() instead of jQuery show() .
Kevin