Deedub Deedub - 1 year ago 66
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download