Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Repeat (clone?) HTML for Dev

Tags:

jquery

I'm using dummy content for a dev site that has about 100 rows or the same HTML - i.e.

<div class="container">
   <div class="row">
    Content
   </div>
   <div class="row">
    Content
   </div>
  <div class="row">
    Content
   </div>
   ... up to 100
</div>

Instead of manually pasting in multiple rows, is there a way to clone that .row div with jQuery and add it to the container x number of times for dev purposes?

like image 681
cusejuice Avatar asked Jul 31 '26 02:07

cusejuice


1 Answers

Have you tried using jQuery's clone method?

var row = $('.row');
for(var i = 0; i < 100; i++ )
   $('.container').append(row.clone())
like image 146
Will Avatar answered Aug 02 '26 16:08

Will



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!