2011-05-25 124 views
1

我用这样的收藏夹http://www.leandrovieira.com/projects/jquery/lightbox/我这里是使用的jQuery的灯箱组图像

<script type="text/javascript"> 
$(function() { 
    // Use this example, or... 
    $('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel 
    // This, or... 
    $('#gallery a').lightBox(); // Select all links in object with gallery ID 
    // This, or... 
    $('a.lightbox').lightBox(); // Select all links with lightbox class 
    // This, or... 
    $('a').lightBox(); // Select all links in the page 
    // ... The possibility are many. Use your creative or choose one in the examples above 
}); 
</script> 

我想组图像,所以我写的网址这样<a href='' rel='lightbox[group1]'></a><a href='' rel='lightbox[group2]'></a>

我怎么跑的? $('a[@rel*=lightbox]').lightBox();不工作,或可能是其他方法?

回答

1

如果你有HTML标签是这样的:

<a href='' rel='group1'></a><a href='' rel='group2'></a>

您可以使用此:

$('a[@rel=group1]').lightBox();$('a[@rel=group2]').lightBox();

0

只写rel=lightbox所有图像组

在与

 $('a[@rel*=lightbox]').lightBox(); 

看到Here

尝试

* 的jQuery( '[属性 = “值”]' ):** 选择具有 s的元素这个属性的值为 ,它包含给定的子字符串。

+0

但是如何分组图像?这将把所有的图像放在一起 – kusanagi 2011-05-25 09:27:58

+0

如果你想要另一个组,然后尝试不同的'rel' – diEcho 2011-05-25 09:55:36

4

我找到简单的解决方案,如果您有很多照片,你不必为每个添加rel。使用div等环绕图像灯箱组

例子:

HTML

<div class="lightbox-group" id="first"> 
<a href="..."><img src="..." /></a> 
<a href="..."><img src="..." /></a> 
<a href="..."><img src="..." /></a> 
</div> 

<div class="lightbox-group" id="second"> 
<a href="..."><img src="..." /></a> 
<a href="..."><img src="..." /></a> 
<a href="..."><img src="..." /></a> 
</div> 

JS

$(document).ready(function() { 
    $('div.lightbox-group').each(function(){ 
     $(this).find('a').lightBox();      
    });  
}); 
0

您必须修改插件像here。这很简单,但像魅力一样。