title: Check if element has any children?
body: <p>I am trying to remove an element from the DOM if it does not contain any elements.</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>var numChildren = 0;
  $("#messages").children().each(function () {
      numChildren += 1;
  });
  if (numChildren &lt;= 0) {
      $("#messages").slideUp("normal", function () { $(this).remove(); });
  }
  </code></pre>