Remove empty elements
HTML
<h2> </h2>
<h2></h2>
<h2> still here <h2>
CSS
h2 {height:100px;width:100px;background:red}
JavaScript
$('h2').filter(function() {
return $.trim($(this).text()).length == 0;
}).remove();
<h2> </h2>
<h2></h2>
<h2> still here <h2>
h2 {height:100px;width:100px;background:red}
$('h2').filter(function() {
return $.trim($(this).text()).length == 0;
}).remove();