How would you write the below code in jQuery?
I have the code working in php, it is to create a way of added a list item with light box and an image. Without having the write each img src and lightbox link out.
<?php
$images = range(1, 3);
$rowCount = 0;
foreach ($images as $image) {
// stripping stuff:
echo '<li class="search-dogs"';
echo '><a href="images/gallery/search-dogs/'.$image.'.jpg" rel="lightbox[gallery]">
<img src="images/gallery/search-dogs/'.$image.'.jpg">
</a></li>';
}
?>
var images = [1,2,3];
var rowCount = 0;
var TargetElement = 'body'; //html tag, .classTag, #htmlElementId
for(var image in images) {
// stripping stuff:
$(TargetElement).append('<li class="search-dogs"><a href="images/gallery/search-dogs/'+image+'.jpg" rel="lightbox[gallery]"><img src="images/gallery/search-dogs/'+image+'.jpg"></a></li>');
}