Howto use variable attribute for Jquery lightbox plugin
I try to implement the JQuery Lightbox plugin with dynamic grouped of images (grouped in image popup), but i can not find the clue for popup grouped images.
Can someone tell me what i'm doing wrong?
HTML
<a href="pic1.jpg" class="pic" rel="lightbox1"><img src="pic1.jpg"/></a>
<a href="pic2.jpg" class="pic" rel="lightbox1"><img src="pic2.jpg"/></a>
<a href="pic3.jpg" class="pic" rel="lightbox2"><img src="pic3.jpg"/></a>
<a href="pic4.jpg" class="pic" rel="lightbox2"><img src="pic4.jpg"/></a>
<a href="pic5.jpg" class="pic" rel="lightbox3"><img src="pic5.jpg"/></a>
<a href="pic6.jpg" class="pic" rel="li开发者_Go百科ghtbox3"><img src="pic6.jpg"/></a>
JQUERY
jQuery(document).ready(function() {
$('a.pic').live('click', function() {
var relvalue = $(this).attr('rel');
$("a[rel="+relvalue+"]").lightBox();
});
});
Thanks!
Did you try this?
jQuery(document).ready(function() {
$('a.pic').lightBox();
});
I assumed you are using krewenki's jquery-lightbox. With $('a.pic').lightBox();
you give to a elements the lightbox ability and with rel attributes on a elements you're grouping them.
精彩评论