lightgallery.js 1.x is not actively maintained . Please upgrade to version 2

Lightgallery methods

This is just a demonstration of how to use lightgallery methods. You can find more methods here

HTML structure

<div id="methods">
  <a href="img/img1.jpg">
      <img src="img/thumb1.jpg" />
  </a>
  <a href="img/img2.jpg">
      <img src="img/thumb2.jpg" />
  </a>
  ...
</div>

Javascript

var el = document.getElementById('methods');

var slide = '<a href="img/img2.jpg">' +
    '<img src="img/thumb2.jpg" />' +
'</a>';

lightGallery(el);

document.getElementById('appendSlide').addEventListener('click', function() {
    el.insertAdjacentHTML('beforeend', slide);
    window.lgData[el.getAttribute('lg-uid')].destroy(true);
    lightGallery(el);
}, false);