Javascript 如何集成一系列图像以形成HTML页面?
我在一个文件夹中有一系列名为image_1.jpg、image_2.jpg等的图像。如何使用Javascript将所有图像连接在一起形成HTML页面?只需添加:Javascript 如何集成一系列图像以形成HTML页面?,javascript,html,Javascript,Html,我在一个文件夹中有一系列名为image_1.jpg、image_2.jpg等的图像。如何使用Javascript将所有图像连接在一起形成HTML页面?只需添加: <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" /> 等等
<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" />
等等
编辑:
你为什么要特别使用javascript来做这件事呢?谢谢你的回复。。。但实际上我有很多图片要添加大约200张。我想添加这些图像使用JavaScript使用for循环,但我不能这样做。。。
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.
}