jQuery: How do I insert an html string an arbitrary number of times (i.e. not with an each() function)?
- by Sam Bivins
I just need to take a certain html query object and append it to an html element a lot of times. I have this:
var box = $("<div class='box'> </div>");
$("#firstbox").after(box);
and it works fine, but it just adds one 'box' after the #firstbox element. I'd like to do something like this:
var box = $("<div class='box'> </div>");
$("#firstbox").after(box * 6000);
so that it will insert 6000 copies of that 'box' html, but this is not working. This is I'm sure the easiest thing to do, but I can't seem to find how to multiply actions like this without using the each() function, which doesn't apply here because I don't have 6000 of anything on my page.
Thanks.