I'm trying to add multiple div's within a div inside for loop:
for( i=0; i<10; i++ )
{
$('#parent').append('<div class="child"></div>");
}
This works perfectly, but when I do:
for( i=0; i<10; i++ )
{
var child = $('<div/>', { class: 'child' });
$("#parent").append(child);
}
I get very strange results, I believe it's because using the second method, the reference instead of the object itself is passed. How can I pass just pure object, no reference, to the append method? thanks!