<div class="bigger"> <img src="images/bigger.png" alt="" id="pro_img" class="bigger" /> <script type="text/javascript" language="javascript"> function change_img(source){ document.getElementById("pro_img").src=source; } </script> </div> //小图部分开始 <ul> <li> <a href="javascript:change_img(‘images/bigger.png‘)"><img class="img_selected" src="images/pz_03.png" /></a> </li> <li><a href="javascript:change_img(‘images/pz_03.png‘)"><img src="images/pz_03.png" /></a></li> <li><a href="javascript:change_img(‘images/bigger.png‘)"><img src="images/pz_03.png" /></a></li> <li><a href="javascript:change_img(‘images/pz_03.png‘)"><img src="images/pz_03.png" /></a></li> <li><a href="javascript:change_img(‘images/pz_03.png‘)"><img src="images/pz_03.png"/></a></li> <li><a href="javascript:change_img(‘images/bigger.png‘)"><img src="images/pz_03.png" /></a></li> <li><a href="javascript:change_img(‘images/pz_03.png‘)"><img src="images/pz_03.png" /></a></li> <li><a href="javascript:change_img(‘images/bigger.png‘)"><img src="images/pz_03.png" /></a></li> <div class="clear"></div> </ul>
很实用的小效果~代码很简单。小图上的每一次点击会触发JS事件,获取大图地址并付给大图所在的img标签。
时间: 2024-10-13 01:03:18