I have a series of images (named as image_1.jpg, image_2.jpg and so on) in a folder. How can all of the images be joined together to form an HTML page using Javascript?
A:
Just add:
<img src="path/to/your/image_1" alt="image_1" />
<img src="path/to/your/image_2" alt="image_2" />
<img src="path/to/your/image_3" alt="image_3" />
etc...
EDIT:
for(var i = 1 ; i < TOTAL_IMAGES ; i ++ )
{
var img = document.createElement('img');
img.src = "path/to/your/image_" + i;
img.alt = "image number " + i;
document.appendChild(img); // this will append the image to the root element. You might want to use a <div> or something instead.
}
Pablo Fernandez
2010-10-25 12:48:59
Thanks for the reply... but actually I have lots of images to add (around 200). I want to add those images using JavaScript (using for loop) but I am unable to do so...
kool4u
2010-10-25 13:02:22
Ok, let me edit the answer
Pablo Fernandez
2010-10-25 14:01:06
Thanks a lot...this is working !!!
kool4u
2010-10-26 05:47:39