JSFiddle - React, Tailwind, and code Playground

by Lisa Poor

HTML

<script src="https://www.datatables.net/release-datatables/media/js/jquery.js"></script>
<script src="https://www.datatables.net/release-datatables/media/js/jquery.dataTables.js"></script>
<script src="https://www.datatables.net/release-datatables/extensions/ColVis/js/dataTables.colVis.js"></script>
<link rel="stylesheet" href="https://www.datatables.net/release-datatables/media/css/jquery.dataTables.css">
<link rel="stylesheet" href="https://www.datatables.net/release-datatables/extensions/ColVis/css/dataTables.colVis.css">
<div style="min-height: 8em;" class="info"></div>
<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th rowspan="2">Name</th>
                <th colspan="2">HR Information</th>
                <th colspan="3">Contact</th>
            </tr>
            <tr>
                <th>Position</th>
                <th>Salary</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>E-mail</th>
            </tr>
        </thead>
 
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Salary</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>E-mail</th>
            </tr>
        </tfoot>
 
        <tbody>
            <tr>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>$320,800</td>
                <td>Edinburgh</td>
                <td>5421</td>
                <td>t.nixon@datatables.net</td>
            </tr>
            <tr>
                <td>Garrett Winters</td>
                <td>Accountant</td>
                <td>$170,750</td>
                <td>Tokyo</td>
                <td>8422</td>
                <td>g.winters@datatables.net</td>
            </tr>
            <tr>
                <td>Ashton Cox</td>
                <td>Junior Technical Author</td>
                <td>$86,000</td>
               ...

JavaScript

$(document).ready(function() {
    var table = $('#example').DataTable({scrollX: true});
    var colvis = new $.fn.dataTable.ColVis( table );
 
    $( colvis.button() ).insertAfter('div.info');
} );