我在一个文件夹中有一系列图像(名为image_1.jpg,image_2.jpg等)。如何将所有图像连接在一起以使用Javascript形成HTML页面?
答案 0 :(得分: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.
}