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 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);