我创建了一个图片库,缩略图,当您单击它们时,大图像将替换为您单击的图像。目前我必须用 html 编写每个文件并为每个文件创建一个单独的 JS 脚本。这是我当前代码的示例:
画廊:
<img id="bigPicMarie" src="assets/Images/MariePeterWeddingImages/Edited/KJ4V7314edit.jpg" alt="banner" />
<div class="captionBox">
<p id="captionText"></p>
</div>
</div> <!-- end of bigPicMarieContainer -->
<div class="floatFix"></div>
<div id="thumbnails" >
<div id="thumbContainerMarie">
<a class="galleryLink" onclick="putPic141();">
<img class="landscape" src="assets/Images/MariePeterWeddingImages/KJ4V7314editthumb.jpg" width="100" alt="thumb" />
</a>
<a class="galleryLink" onclick="putPic142();">
<img class="portrait" src="assets/Images/MariePeterWeddingImages/MM_24083editthumb.jpg" width="100" alt="thumb" />
</a>
<a class="galleryLink" onclick="putPic143();">
<img class="landscape" src="assets/Images/MariePeterWeddingImages/MM_24089editthumb.jpg" width="100" alt="thumb" />
</a>
JS:
//Marie&PeterWeddingAlbum//
function putPic141(){
document.getElementById('bigPicMarie').src = "assets/Images/MariePeterWeddingImages/Edited/KJ4V7314edit.jpg";
document.getElementById('captionText').innerHTML = 'IMG001';
}//end putPic141
function putPic142(){
document.getElementById('bigPicMarie').src = "assets/Images/MariePeterWeddingImages/Edited/MM_24083edit.jpg";
document.getElementById('captionText').innerHTML = 'IMG002';
}//end putPic142
画廊外观示例:http ://www.jamielouise.co.uk/portraits.html
我想要的是一种使画廊从指定文件夹中的所有图像自动生成的方法。理想情况下,我希望它以与当前相同的方式出现和运行。