使JQuery LightBox插件可以与多个库一起使用 [英] Making JQuery LightBox Plugin work with multiple galleries
问题描述
我正在尝试制作这个jquery插件=> http://leandrovieira.com/projects/ jquery / lightbox /
在同一页面上使用多个图库。
I'm trying to make this jquery plugin => http://leandrovieira.com/projects/jquery/lightbox/ work with multiple galleries on the same page.
问题是,每次我点击某个图库中的图片,我从同一页面上的所有画廊中获取所有照片。假设我有2张画廊,每张6张照片。如果我点击图库1中的图片,我也会看到图库2中的图片。
The problem is, everytime I click on a picture from a certain gallery, I get all the pictures from all the galleries on the same page. Let's say i've got 2 galleries of 6 photos each. If I click on a pic from gallery 1, I will see the pics from gallery 2 as well.
我尝试过类似的东西让它工作但没有成功:
I've tried something like this to make it work but no success:
<script type="text/javascript">
$(function(){
$('div.gallery-6').each(function() {
$(this).find('a.lightbox').lightBox();
});
});
</script>
不幸的是,它不起作用!!!
Unfortunately, it doesn't work!!!
这是什么解决方法?
再一次,我想要完成的是能够在他们合适的画廊中查看图片。我不希望所有的照片都被视为一个画廊。
Once again, what I'm trying to accomplish is to be able to view the pictures in their proper gallery. I don't want all the pics to be treated as one gallery.
推荐答案
我做了很多改变我用多个一页上的画廊。
With very few changes I made this work with multiple galleries on one page.
JQuery
$(function() {
$('#gallery1 a').lightBox();
$('#gallery2 a').lightBox();
...
$('#galleryN a').lightBox();
});
HTML
<div class="gallery" id="gallery1">
<div class="gallery" id="gallery2">
...
<div class="gallery" id="galleryN">
我将样式从id更改为类。
I changed the style from an id to a class.
这篇关于使JQuery LightBox插件可以与多个库一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!