I
I
igorc752019-03-25 08:33:04
JavaScript
igorc75, 2019-03-25 08:33:04

Set up blueimp-gallery together?

Hello!
There is a script for viewing pictures in the blueimp-gallery gallery. Here is the script that is applied to the gallery with id="gallery".

document.getElementById('gallery').onclick = function (event) {
        event = event || window.event;
        var target = event.target || event.srcElement,
            link = target.src ? target.parentNode : target,
            options = {index: link, event: event},
            links = this.getElementsByTagName('a');
        blueimp.Gallery(links, options);
    };

But if you need several such galleries on the page, independent of each other.
Tried to implement via CLASS but couldn't get it to run. Might notice an error.
document.getElementsByClassName('gallery')[0].onclick = function (event) {
          event = event || window.event;
          var target = event.target || event.srcElement,
              link = target.src ? target.parentNode : target,
              options = {index: link, event: event},
              links = this.getElementsByTagName('a');
          blueimp.Gallery(links, options);
      };

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question