2010-10-25 19 views
0

我在一个文件夹中有一系列图像(名称为image_1.jpg,image_2.jpg等)。如何将所有图像连接在一起形成使用Javascript的HTML页面?如何整合一系列图像以形成HTML页面?

+0

在那里你为什么要这么做专门使用JavaScript的一个原因? – Irfy 2010-10-25 12:51:30

回答

0

只需添加:

<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" /> 

等等

编辑:

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. 
} 
+0

感谢您的回复......但实际上我有很多图片要添加(200左右)。我想使用JavaScript添加这些图像(使用for循环),但我无法这样做... – Ratan 2010-10-25 13:02:22

+0

好吧,让我编辑答案 – 2010-10-25 14:01:06

+0

非常感谢...这是工作! – Ratan 2010-10-26 05:47:39