I can easily remove a tag that has no blank spaces...
$(\'h2:empty\').remove();
But, when there is a space...
&l
try this
$("h2").each(function(){ var self = $(this); if ( self.html().trim().length == 0 ) { self.remove(); } });