title: Javascript - Remove empty paragraphs from HTML string
body: <p>In a Javascript object, I have a string of HTML (<code>node.innerHTML</code>) and I need to remove empty paragraphs from the string, then return the string.  Empty paragraphs include <code>&lt;p&gt;&lt;/p&gt;</code>, <code>&lt;p&gt; &lt;/p&gt;</code>, and <code>&lt;p&gt;&amp;nbsp;&lt;/p&gt;</code>. Ideally, I think the string should be parsed as HTML code for processing as opposed to using a regex.  I have tried all sorts of approaches and cannot seem to get it to work correctly.</p>
  
  <p>Here is code I have tried, but it returns an object with only prevObject data, plus it does not seem to remove the empty paragraphs.</p>
  
  <pre><code>function strip_empty_p (node) {     
      var html = $(node.innerHTML);
      html = html.filter($('p'),function () {
          return this.innerHTML == "" ||
          this.innerHTML == " " ||
          this.innerHTML == "&amp;nbsp;"
          }).remove();    
      node.innerHTML = html.innerHTML;
      return node.innerHTML;
  }
  </code></pre>