JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/sl-1.4.0/datatables.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/sl-1.4.0/datatables.min.js"></script>
<table class="table" id="the-table">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr>
<td>Content</td>
</tr>
</tbody>
</table>
<hr>
<button class="btn btn-warning" id="the-button">Destroy DataTable</button>
JavaScript
var dataTable = $('#the-table').DataTable({
select: true,
});
dataTable.on('deselect', function (e, dt, type, indexes) {
console.log('"deselect" triggered!');
});
$('#the-button').on('click', function () {
console.log('Destroying dataTable...')
dataTable.destroy();
console.log('Destroyed dataTable!')
});