I created a version that maybe perform a little better than using a lot of CSS3 selectors in jQuery.
$(function () {
var $table = $('#mytable'),
$thead = $table.find('thead'),
$tbody = $table.find('tbody');
var isEmpty = {};
$tbody.find('td').each(function () {
var $this = $(this);
if ( $this.text() == '' && isEmpty[ $this.index() ] != false ) {
isEmpty[ $this.index() ] = true;
} else {
isEmpty[ $this.index() ] = false;
}
});
for (var x in isEmpty) {
if ( isEmpty[x] ) {
$thead.find('th').eq( x ).remove();
$tbody.find('td:nth-child(' + (parseInt(x, 10) + 1) + ')').remove();
}
}
});