I have a question about how to rewrite a lightbox script that uses jquery.
Its using div ids to differentiate galleries. I’d like to have it use the rel="" attribute, with perhaps a trailing number. Can this be written to check for something such as rel="gallery1" but within a loop that increments the number? I’m unfamiliar with the js syntax for such things. Or perhaps a loop with checks the dom for objects with that rel. Thx.
Javascript
$(function() {
$('#gallery1 a').lightBox();
$('#gallery2 a').lightBox();
});
This will loop through a for loop 3 times calling
.lightBox()on links withrelofgallery1,gallery2andgallery3. You can increase the loop number to however many you want.Javascript
Although I think you can group lightboxes just by specifying different
relproperties and calling.lightBox()on all the links.Give all your lightbox links a class of
lightboxand then specify differentrelgroups such asgallery1,gallery2andgallery3for all the links. Then call the following, I think.lightBox()and they should all be grouped seperately.HTML
Javascript
What should happen is
gallery1links group together, thegallery2links group together and thegallery3links group together. This should happen by default.I hope this helps.
Edit 1
Something to note, the jQuery lightbox plugin has not been updated for 4.5 years. You may want to look at a better maintained alternative like colorbox.