I want to delete the whole column if it's empty.
This code is the only one I found that works, just always every column is deleted except the last one even if it's empty. I don't know why. Any help is highly appreciated.
this is how my page looks :
/* loop over each th */
$('th').each(function(idx, el) {
/* check every td in the same column, see if they contain any text */
var check = !!$('tr').find('td:eq(' + idx + ')').filter(function() {
return $.trim($(this).text()).length;
}).length;
/* toggle the display of each th and td in this column, based on the check above */
$('tr').find('td:eq(' + idx + '), th:eq(' + idx + ')').toggle(check);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
