If you don't want deep clones, then you can use the array join()
method to create an HTMLString corresponding to n
number of elements as shown below:
var elementString = new Array(++n).join($(selector).get(0).outerHTML)
which you can append to any element you wish.
Basically we pass the outerHTML of the element to an arrays join()
method, whose length is 1
more than the number of clones required. This is because the join()
method starts appending after the first element and stops prior to the last one.
i.e,
[null,null,null,null].join(","); // results in ",,," not ",,,,"
In your case you can do:
$("ul").append(new Array(8).join($(".one_element").get(0).outerHTML));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="my_list">
<li class="one_element">data</li>
</ul>