lightGallery Dynamic mode Demo

by Sachin N

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/js/lightgallery.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/css/lightgallery.css">
<a id="dynamic" href>Open lightGallery</a>

CSS

#dynamic {
  border: 1px solid #e6e6e6;
  background-color: #ce4844;
  color: #FFF;
  padding: 10px 20px;
}

JavaScript

$('#dynamic').on('click', function(e) {
 		
    e.preventDefault();
    $(this).lightGallery({
        dynamic: true,
        dynamicEl: [{
            src: 'http://sachinchoolur.github.io/lightGallery/static/img/1.jpg'
        },{
            src: 'http://sachinchoolur.github.io/lightGallery/static/img/2.jpg'
        },{
            src: 'http://sachinchoolur.github.io/lightGallery/static/img/3.jpg'
        },{
            src: 'http://sachinchoolur.github.io/lightGallery/static/img/4.jpg'
        }]
    })
 
});