我在这里有一个简单的 jQuery 画廊:http: //encoreazalea.com/ee/the-collection/in-the-landscape
当您单击其中一个缩略图时,较大的图像应该显示在预览图像区域的左侧。但是,它会在另一个窗口中打开。
这是HTML:
<div id="preview">
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape16.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape15.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape14.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape12.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape13.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape11.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape10.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape9.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape8.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape6.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape7.jpg" class="gallery" alt="photo gallery" />
<img id="photo_large" src="http://encoreazalea.com/ee/landscape-gallery/landscape5.jpg" class="gallery" alt="photo gallery" />
</div>
</div><!-- end #content-hub -->
<div id="sidebar">
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape16.jpg" title="Landscape16"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape16_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape15.jpg" title="Landscape15"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape15_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape14.jpg" title="Landscape14"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape14_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape12.jpg" title="Landscape12"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape12_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape13.jpg" title="Landscape13"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape13_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape11.jpg" title="Landscape11"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape11_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape10.jpg" title="Landscape10"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape10_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape9.jpg" title="Landscape9"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape9_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape8.jpg" title="Landscape8"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape8_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape6.jpg" title="Landscape6"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape6_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape7.jpg" title="Landscape7"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape7_tn.jpg" alt="photo gallery" /></a>
<a href="http://encoreazalea.com/ee/landscape-gallery/landscape5.jpg" title="Landscape5"><img class="gallery" src="http://encoreazalea.com/ee/landscape-gallery/landscape5_tn.jpg" alt="photo gallery" /></a>
</div><!-- end #sidebar -->
这是jQuery:
<script type="text/javascript">
$(document).ready(function() {
$("a:has(img.gallery)").click(function() {
var largePath = $(this).attr("href");
var caption = $(this).attr("title");
$("#photo_large").attr({ src: largePath});
$("#caption1").text(caption);
return false;
});
});
</script>
我可以用一些有更好处方的眼睛来看看这个,帮助我看看我错过了什么。
谢谢。