title: Count number of dynamically generated list element in an unordered list
body: <p>I have a menu that is generated from an XML file. The XML file is loaded using AJAX. The only html in the menu that is hard coded is:</p>
  
  <pre><code>&lt;div id="leftNav"&gt;
      &lt;ul class="level1"&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>the rest of the menu is dynamically created based on the contents of the XML file. In the Chrome inspector all the list elements that should be in the menu are there. Now when I try to count the number of list elements I get 0. I figure it's because there are no list elements hard coded on the page. The code I use to do the counting is:</p>
  
  <pre><code>alert($('.level1 &gt; li').size());
  </code></pre>
  
  <p>which alerts 0. </p>
  
  <p>EDIT- i misplaced the function call and the xml had not finished loading. the code does work as expected. </p>
  
  <p>The function that parses the XML and generates the extra list items runs before I try to count the list items.</p>
  
  <p>Any ideas as to how to get the number of list items?</p>