How to hide jQuery datatables

Rajaram Shelar picture Rajaram Shelar · Apr 5, 2013 · Viewed 21.8k times · Source

How do I to hide jQuery datatables, when I want to toggle the datatable's visibility? The problem is if I write hide statement it only hides the rows, not the headers and footer. How can I hide datatable fully?

For hiding, I used the below code:

 var oTable = $('#example').dataTable(); // 'example is the table id'
 oTable.hide();

Answer

msapkal picture msapkal · Apr 5, 2013

Try this

$('#example').parents('div.dataTables_wrapper').first().hide();