If you are going to be repeatedly inserting HTML (such as through a loop) then I'd use a jQuery templating plug-in. I prefer the one that Microsoft made from John Resig's original design. It gets the job done. Read about it here.
It works like this...
Define a template in the section of your page.
<script id="myTemplate" type="text/html">
<div>
<h3>${headerText}</h3>
<p>${someText}</p>
<a href="${linkHref}">Click Me</a>
</div>
</script>
Here some test data:
var testData =
{
headerText: 'Hello World',
someText: 'A long random paragraph about nothing, or Lorem Ipsum.. yadayaya',
href: 'http://www.stackoverflow.com/'
}
Then you can use the template anytime and as much as you want:
$('#myTemplate').tmpl(testData).appendTo('body');
Results in:
<div>
<h3>Hello World</h3>
<p>A long random paragraph about nothing, or Lorem Ipsum.. yadayaya</p>
<a href="http://www.stackoverflow.com/">Click Me</a>
</div>
You can create as complex structures as you want. It's very easy to read and maintain.
Enjoy :)
Then you can use this repeatedly.