JSFiddle - React, Tailwind, and code Playground
HTML
<table id="mytable" border="1">
<tr><th>Column1</th><th>Column2</th><th>Column3</th><th>Column4</th></tr>
<tr class="data"><td>1st</td><td>1.1</td><td></td><td></td></tr>
<tr class="data"><td>2nd</td><td>2.1</td><td></td><td></td></tr>
<tr class="data"><td>3rd</td><td>3.1</td><td></td><td>2</td></tr>
<tr class="data"><td>4th</td><td></td><td></td><td></td></tr>
<tr class="data"><td></td><td></td><td></td><td></td></tr>
<tr class="data"><td></td><td></td><td></td><td></td></tr>
</table>
<br />
<table id="mytable2" border="1">
<tr><th>Column1</th><th>Column2</th><th>Column3</th><th>Column4</th><th>Column5</th></tr>
<tr class="data"><td>1st</td><td>1.01</td><td></td><td></td><td></td></tr>
<tr class="data"><td>2nd</td><td>2.01</td><td></td><td></td><td></td></tr>
<tr class="data"><td>3rd</td><td>3.01</td><td></td><td></td><td></td></tr>
<tr class="data"><td>4th</td><td>4.01</td><td></td><td></td><td>x</td></tr>
<tr class="data"><td>5th</td><td>5.01</td><td>c</td><td></td><td></td></tr>
</table>
JavaScript
$('table').each(function(a, tbl) {
var currentTableRows = $(tbl).find('tr').length - 1;
$(tbl).find('th').each(function(i) {
var remove = 0;
var currentTable = $(this).parents('table');
var tds = currentTable.find('tr td:nth-child(' + (i + 1) + ')');
tds.each(function(j) { if (this.innerHTML == '') remove++; });
if (remove == currentTableRows) {
$(this).hide();
tds.hide();
}
});
});