I'm new to jquery and javascript so sorry if this question seems stupid.
I try to load in several div the content (images) of corresponding folders to make a gallery.
<div id="menu">
<div class="gallery" id="div0">ok0</div>
<div class="gallery" id="div1">ok1</div>
<div class="gallery" id="div2">ok2</div>
<div class="gallery" id="div3">ok3</div>
<div class="gallery" id="div4">ok4</div>
<div class="gallery" id="div5">ok5</div>
</div>
<script>
var $container = $("#menu div.gallery");
$container.each(function(){
var $n = $(this).attr('id');
tl = 0;
var img = ["0001","0002","0003","0004","0005","0006","0007","0008","0009"];
$.each(img,function (i, v) {
$container.append('<div class="gallery_img" style="top:' + tl + 'px; left:' + tl + 'px; background-image:url(imgsmall/'+ $n +'/'+ v +'.jpg);"></div>');
tl += 8;});
});
$container.width(tl + 200).height(tl + 200).find("div").mouseover(
function () {
$(this).topZIndex();
}
);
</script>
Every div id correspond to the name of the folder but i can't find the way to upload the content of the good folder in the good div because of the $container.each() function and the $.each() one. this way it uploads the content of all folders in every div.
Also how can i replace this array
var img = ["0001","0002","0003","0004","0005","0006","0007","0008","0009"];
with something neat?