This is just a demonstration of how to use lightgallery methods. You can find more methods here
<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>
var $methods = $('#methods'); var slide = '<a href="img/img2.jpg">' + '<img src="img/thumb2.jpg" />' + '</a>'; $methods.lightGallery(); $('#appendSlide').on('click', function() { $methods.append(slide); $methods.data('lightGallery').destroy(true); $methods.lightGallery(); });