c:foreach中循环
<td class="center">
<a href="javascript:void(0);" data-toggle="modal" data-target="#myModal" onclick="lookImg(${i.houPicture})">
<img style="width: 80px;height: 35px;" src="http://图片地址/${i.houPicture}.jpg">
</a>
</td>
模态框
<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated bounceInRight">
<button type="button" class="close" data-dismiss="modal" style="color: red;"><span aria-hidden="true">×</span><span class="sr-only">关闭</span>
</button>
<div id="myimg" style="width: 600px;height: 500px;">
</div>
</div>
</div>
</div>
js
function lookImg(id) {
var myimg = document.getElementById("myimg");
myimg.innerHTML = "<img style='width: 100%;height: 100%;' src='图片路径"+id+".jpg'>"
}
这篇博客介绍了如何在HTML中利用c:forEach标签循环显示一组图片,并且每张图片点击后能够通过模态框以大图形式查看。在代码示例中,每个图片链接都绑定了一个JavaScript函数lookImg(),该函数动态改变模态框内图片的源,从而实现查看大图的效果。

被折叠的 条评论
为什么被折叠?



