How to clear a data table on button click jQuery
Clearing a data table on button click jQuery
In many of the scenarios we have to clear a datatable on an event as its previous data is no longer in use, to achieve this there might be many approaches. I have used below approach to clear a datatable on button click using jQuery.
Code -
$("#submit").on("click", function(){
if ($('#tblData tbody tr').length > 0)
{
$('#tblData thead').remove();
$('#tblData tbody').empty();
$('#tblData').DataTable().destroy();
}
});
Comments
Post a Comment