Search code examples
javascriptjquerycloneduplication

How to duplicate list element more than one time with jQuery


i have i little question. Is there any option to duplicate more than one element with jquery? I have one element list, can i clone, duplicate it f.e. 7 times?

<ul id="my_list>
   <li class="one_element>data</li>
</ul>

and some jquery, i have no idea how to write this:

var mylist = $('#my_list');
myList.find('li').clone(2);

Can u help me? Thx.


Solution

  • var mylist = $('#my_list');
    for ( i = 0; i < 7;i++){
          mylist.find('li:first').clone().appendTo(mylist);
    }