Try: $('li', this).length;
On Feb 19, 3:14 pm, Tim <tim.myer...@gmail.com> wrote: > So I have a main list of states in an unordered list and then a > unordered list of cities within each of those. So I wanted to count > the number of cities per state. > <ul class="state_list"> > <li> > <h2>Alabama</h2> > <ul> > <li><a href="http://www.google.com">Alabama State</a></li> > <li><a href="http://www.google.com">Alabama State</a></li> > <li><a href="http://www.google.com">Alabama State</a></li> > <li><a href="http://www.google.com">Alabama State</a></li> > </ul> > </li> > </ul> > > $('.state_list > li').each(function(i){ > $(this+ '> li').count(); > }); > > It will let me put anything inside of the each function except for > counting or length, when I do that it blows up the whole site without > any errors..