STRIP EMPTY TAGS

by bizamajig

HTML

<p></p>
<p> </p>
<p>&nbsp;</p>
<p>
</p>
<p>Where is pancakes house?</p>

CSS

p {
    margin: 1em;
    border: 1px solid red;
}

JavaScript

$('p').each(function() {
    var $this = $(this);
    if($this.html().replace(/\s|&nbsp;/g, '').length == 0)
        $this.remove();
});