calculating the number of first level UL LI in a page using jquery
<p>I have some jquery which will calculate the items in my menu and assign the li with a calculated width in px. </p>

<p>here is the code:</p>

<pre><code>$(document).ready(function(){
    $('div#new-menu-lower ul li').css('width', ($('div#new-menu-lower ul').width() / $('div#new-menu-lower ul li').length));
    $(function() {
        var menuWidth = $('div#new-menu-lower ul').width();
        var listItems = $('div#new-menu-lower ul li').length;
        var itemWidth = Math.floor(menuWidth * (1/listItems)) - 40;
        $('div#new-menu-lower ul li').css('width', itemWidth);
    });
});
</code></pre>

<p>The problem is <code>listItems</code> shows up as 38 items and it seems to calculate every single li which is wrong. It should just count the first ul li's NOT the child elements.</p>

<p>Is there anything i can do to stop this happening?</p>
