I was doing this for "tr/td/div"s today and it worked wonders .
for (i = 0; i < myArray.length; i++) {
$("#divId").append($('<li>')myArray[i]);
}
the closing tags aren't needed . hope this helps
EDIT
I found this pretty handy because you can dynamically assign id's to DOM elements like
for (i = 0; i < myArray.length; i++) {
$("#divId").append($('<li id="myLi'+i+'">')myArray[i]);
}
and end up with
<li id="myLi1">
<li id="myLi2">
etc
To append "< p >" before the etc you can use this sort of concept that i used today :) the nesting of the brackets is very important here
for (var i = 0; i < listOfNames.length; i++) {
$("#table").find('tbody')
.append($('<tr>')
.append($('<td style="width: 300px">')
.append($('<div id="div'+i+'" style="display: inline-block">'))
.append($('<a >')
.append($('<img src="../.gif" alt="Loading..." ' +
'id="Icon' + i + '" style="float: right">')
)
)
)
).append($('<tr id="InfoRow' + i + '">')
.append($('<td>')
.append('<div id="Info' + i + '" style="display: inline-block;">')
)
);
$('#nameText'+i).text(listOfNames[i]);
}
This is basically what it spits out to give you an idea
<tr>
<td style="width: 300px"><div id="div1" style="display: inline-block"></div><a><img src=".gif" alt="Loading..."id="Icon1" style="float: right"/></a></td>
</tr>
<tr id="InfoRow1">
<td><div id="Info1" style="display: inline-block;float: right"></div>/td>
</tr>