html - Create a list item dynamically using two file paths JQuery -
ok explain best can
what
is create jquery function create list 2 different folders give me 30 images
<div id="box"> <ul> <li><a href="images/test1.jpg"><img src="imagesthumbs/test1.jpg" alt="" /></a></li> <li><a href="images/test2.jpg"><img src="imagesthumbs/test2.jpg" alt="" /></a></li> <li><a href="images/test3.jpg"><img src="imagesthumbs/test3.jpg" alt="" /></a></li> </ul> </div>
it possible whats simplest way of writing this?
thanks
sho
lets have 2 arrays 2 different folders. can try this
var images = ["test1.jpg", "test2.jpg"]; var imagesthumbs = ["test1.jpg", "test2.jpg"]; var ul = $("<ul/>"); $.each(images, function(i, val){ $("<li/>") .append($("a", {href:"images/"+val}).append("img", {src:imagesthumbs[i], alt:""})) .appendtp(ul); }); $("#box").append(ul);
Comments
Post a Comment