Clear DataTable on button click
How to clear DataTable on button click
In this post we will learn how we can clear a datatable on a jQuery event. By click on "btnReset" we have to call datatable's destroy method to completely clear a datatable. We may need to clear a datatable on an event. Please follow the below code to achieve the same.
HTML -
<table id="tblResourcesData" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Title</th>
<th>Region</th>
<th>Country</th>
<th>Email</th>
</tr>
</thead>
</table>
Code -
$("#btnReset").click(function(){
$('#tblResourcesData').DataTable().destroy();
$('#tblResourcesData tbody').empty();
});
Comments
Post a Comment