我有以下内容:
<div class="gallery">
<a href="http://via.placeholder.com/200x100?text=A1">
<img src="http://via.placeholder.com/200x100?text=A1"/>
</a>
<a href="http://via.placeholder.com/200x100?text=A2">
<img src="http://via.placeholder.com/200x100?text=A2"/>
</a>
</div>
<div class="gallery">
<a href="http://via.placeholder.com/200x100?text=B1">
<img src="http://via.placeholder.com/200x100?text=B1"/>
</a>
<a href="http://via.placeholder.com/200x100?text=B2">
<img src="http://via.placeholder.com/200x100?text=B2"/>
</a>
</div>
然后使用http://dbrekalo.github.io/simpleLightbox我有:
$('.gallery a').simpleLightbox();
但这使得画廊“看到”页面中的所有图像都是同一个画廊。
我怎么称呼simpleLightbox
所以每个Gallery Div都被视为画廊?
请注意,我在页面中有两个以上的画廊。
你可以在.each
上使用.gallery
并启动个人a
的.gallery
插件
$('.gallery').each(function(){
$(this).find("a").simpleLightbox();
})