Nested loop in JavaScript/jQuery not working
<p>Im calling a for loop inside a for loop and its not working, here's the code :  </p>

<pre><code>function PopulateMonths() {
for (var m = 0; m &lt; 12; m++) {
    var $month = $('.d-month').clone();
    $month.find('.d-header').text(m);
    $month = PopulateDays($month);
    $month.appendTo('#diary').show();
    $month = null;
}
}

function PopulateDays($month) {
for (var d = 0; d &lt; 30; d++) {
    var $row = $('.d-row').clone();
    $row.find('.d-day').text(d);
    $row.appendTo($month).show();
    $row = null;
}
return $month;
}
</code></pre>

<p>If I call PopulateDays manually 12 times it works fine, as soon as I try to loop 12 times using PopulateMonths() the page crashes, CPU usage goes through the roof so im assuming a lot of work is going on.</p>

<p>What am I missing?</p>
