title: Count all first list items in ul
body: <p>I was wondering how to count all the list items inside a div.</p>
  
  <pre><code>&lt;ul class="menu"&gt;
      &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a&gt;Information&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a href="#"&gt;History&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Present&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Future&lt;/a&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a&gt;Tutorials&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a href="#"&gt;HTML/CSS&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Javascript&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;Jquery&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;&lt;a href="#"&gt;PHP&lt;/a&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Structure&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>How do I count all the list elements inside <code>ul class=menu</code>? And not the list items who are in a deeper UL.</p>
  
  <p>What I mean is how to count Home, Contact, Information, Tutorials, Structure, and not the list elements who are inside these I just mentioned.</p>
  
  <p>Of course I did some research but couldn't find the correct answer.
  Here is somewhat of a duplicate: <a href="https://stackoverflow.com/questions/605969/jquery-count-number-of-list-elements">jQuery: Count number of list elements?</a></p>