JSFiddle - React, Tailwind, and code Playground

HTML

<table id="test" border="1">
    <tr>
        <th>col1</th>
        <th>col2</th>
        <th>col3</th>
    </tr>
    <tr>
        <td>col1</td>
        <td></td> 
        <td>col3</td>
    </tr>
    <tr>
        <td>col1</td>
        <td></td> 
        <td>col3</td>
    </tr>
</table>

JavaScript

$('#test tr th').each(function(i) {
        //select all tds in this column
        var tds = $(this).parents('table')
            .find('tr td:nth-child(' + (i + 1) + ')');
        if(tds.is(':empty')) {
            //hide header
            $(this).hide();
            //hide cells
            tds.hide();
        } 
    });