Count items for each list on the page
<p>I have a page with multiple lists. Each list has a different amount of list items.
I want to show a less/more link after every third list item and I would like to hide the less/more link if my list has less than 3 items in it.</p>

<p>This is what I've got so far:</p>

<pre><code>    var n = $('ol.checkboxes').children.length;

    if (n &gt; 3) {
           $('ol.checkboxes')
            .find('li:gt(2)')
            .addClass('toggleli')
            .hide()
            .end()
            .append(
                 $('&lt;li class="collapsed"&gt;More&gt;&gt;  &lt;/li&gt;').click(function(){
                 $(this).siblings('.toggleli').toggle();
              if($(this).hasClass('expanded')){
                  $(this).text(metaData['MORE_TEXT']);
                  $(this).removeClass('expanded');
              } else{
                  $(this).text(metaData['LESS_TEXT']);
                  $(this).addClass('expanded');
              }
        }));
       }
     });
</code></pre>

<p>Unfortunately, this counts all the list items that are in a ol.checkboxes..
Any help would be greatly appreciated!   </p>
