Deedub Deedub - 2 months ago 8x
jQuery Question

Using Jquery for each() on list item to output count

I have the following:


<div id="output">

I want output another list (#output) based on the number of lis.I can't wrapt my brain around exactly what to use. Am thinking it would be "count the number of lis in this ul, then for each, output the count/index into the #output div.

Any help is appreciated.


You could try doing something like this:

$('ul li').each(function(){
    $('#output ul').append('<li></li>');

Obviously, adjusting it to however you need. Also, you'll need an identifier on the original ul.