havvg's playground

Developing Software is Fun!

jQuery lightBox with multiple galleries on one page

Toni Uebernickel

Lightbox is one great plugin for jQuery. As there is no option to set up relations for links of images to generate galleries of it like thickbox does, you have to call lightBox multiple times to get your galleries up and separated from each other.

A simple call for lightBox looks something like this.

$('#photos .gallery a').lightBox();

Imagine you have several separated elements of the class gallery nested under the photos node. LightBox will put all of these images in one gallery.

The following code snippet will call lightBox multiple times separating each gallery from all others.

$('#photos .gallery').each(function() {
  $('a', $(this)).lightBox();
});
blog comments powered by Disqus
Written by

Toni Uebernickel

Software Engineer and Architect, Symfony evangelist with some Ducati bikes.

Support & Share
You should subscribe to my feed!
All content copyright Toni Uebernickel © 2018 • All rights reserved.