I'm working on a 3 columns photo website (responsive), and I'm parsing the img src from a XML.I need to prepend a HTML code every 3 elements so my photo wall respect my responsive class. I just found a cheap solution, repeating the xml loop (for).Do you have an advice to give me, to do it right ?ThanksThis is my code :\[code\]$(document).ready(function(){ xmldata=http://stackoverflow.com/questions/14073551/new Array(); //initialise array for XML data $.ajax({ //get the XML data url:"xml/gallery.xml", //URL to get the data from success: function(data) { //if we succeed, set everything up. We don't expect failure. $(data).find("image").each(function() { xmldata.push($(this)); //add item into array }); totalNum = xmldata.length; gallery_images(); } }); });function gallery_images(){for (var i = 0; i <= 2; i++) { data=http://stackoverflow.com/questions/14073551/xmldata; img_src=$(data).attr("src"); href=http://stackoverflow.com/questions/14073551/$(data).attr("href"); title1=$(data).attr("title1"); client=$(data).attr("client"); var video_gallery_html = ''; video_gallery_html += '<article class="col span_8"><div class="title_div span_24 ">'; video_gallery_html += ' <a href="http://stackoverflow.com/questions/14073551/#"> <img src="http://stackoverflow.com/questions/14073551/images/linea.png" alt="line_divisor" /></a>'; video_gallery_html += ' <h1 class="title_item col span_12 _left">DENIS ROVIRA</h1>'; video_gallery_html += ' <h3 class="title_more col span_12 _right">See all projects</h3></div><!-- title_div -->'; video_gallery_html += ' <a href="http://stackoverflow.com/questions/14073551/#"> <img src="'+ img_src +'" alt="image_item" /></a>'; video_gallery_html += ' <p>Nescafe Gold</p></article><!-- span_8 -->'; $(".videos_container").prepend(video_gallery_html); }; for (var i = 3; i <= 5; i++) { data=http://stackoverflow.com/questions/14073551/xmldata; img_src=$(data).attr("src"); href=http://stackoverflow.com/questions/14073551/$(data).attr("href"); title1=$(data).attr("title1"); client=$(data).attr("client"); var video_gallery_html2 = ''; video_gallery_html2 += '<article class="col span_8"><div class="title_div span_24 ">'; video_gallery_html2 += ' <a href="http://stackoverflow.com/questions/14073551/#"> <img src="http://stackoverflow.com/questions/14073551/images/linea.png" alt="line_divisor" /></a>'; video_gallery_html2 += ' <h1 class="title_item col span_12 _left">DENIS ROVIRA</h1>'; video_gallery_html2 += ' <h3 class="title_more col span_12 _right">See all projects</h3></div><!-- title_div -->'; video_gallery_html2 += ' <a href="http://stackoverflow.com/questions/14073551/#"> <img src="'+ img_src +'" alt="image_item" /></a>'; video_gallery_html2 += ' <p>Nescafe Gold</p></article><!-- span_8 -->'; $(".videos_container2").prepend(video_gallery_html2); };} \[/code\]