title: jQuery: size/length of dynamically loaded elements
body: <p>I have a form and I'm dynamically adding new input &amp; select elements in to it via jQuery's load function. Sometimes the loaded elements are in purpose empty and in that case I want to hide the container div so it won't break the style.</p>
  
  <p>The problem is, that I seem to be unable to count the loaded elements and therefore don't know if it should be hidden or not.</p>
  
  <p>For example I have this:</p>
  
  <pre><code>&lt;div id="param_container"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>And on some dropdown menu change I have binded this function:</p>
  
  <pre><code>alert($('#param_container').children().length);
  
  // Returns and loads new element correctly. Can be empty.
  $('#param_container').load('/get_params', {cat:category});
  
  if ($('#param_container').children().length ) {
      $('#param_container').css('display', 'block');
  } else {
      $('#param_container').css('display', 'none');
  }
  
  alert($('#param_container').children().length);
  </code></pre>
  
  <p>The length of the children are always 0 even though new children element has been added.</p>
  
  <p>Any thoughts?</p>
  
  <p>EDIT:</p>
  
  <p>My solution</p>
  
  <pre><code>$('#param_container').load('/get_params', {cat:category}, function(response) {
      if (response) {
          $('#param_container').css('display', 'block');
      } else {
          $('#param_container').css('display', 'none');
      }
  });
  </code></pre>