title: Javascript: How to target lightgallery.js on dynamic added elements
body: <p>I'm trying to target dynamic added elements to work with lightgallery.js. See the exemple bellow:</p>
  <pre class="lang-html prettyprint-override"><code>    &lt;div id=&quot;animated-thumbs&quot; class=&quot;page-divs-middle&quot;&gt;
          &lt;!-- STATIC EXAMPLE --&gt;
          &lt;div class=&quot;col-md-3 col-xs-3 text-nowrap spacer-page-models fit pulsar&quot;&gt;
           &lt;a href=&quot;assets/img/01.jpg&quot; data-lightbox=&quot;image-1&quot;&gt;
              &lt;img class=&quot;img-responsive img-responsive-center cover&quot; src=&quot;assets/img/01.jpg&quot;&gt;
           &lt;/a&gt;
      &lt;/div&gt;
          &lt;div class=&quot;col-md-3 col-xs-3 text-nowrap spacer-page-models fit pulsar&quot;&gt;
            &lt;a href=&quot;assets/img/01.jpg&quot; data-lightbox=&quot;image-1&quot;&gt;
              &lt;img class=&quot;img-responsive img-responsive-center cover&quot; src=&quot;assets/img/01.jpg&quot;&gt;
              &lt;/a&gt;
          &lt;/div&gt;               
          &lt;!-- STATIC EXAMPLE --&gt;
      &lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function(){
      $('#animated-thumbs').lightGallery({
       thumbnail:true,
       selector: 'a',
       download:false,
       share:false,
       autoplayControls: false,
      });
     })
  &lt;/script&gt;
  </code></pre>
  <p>The code above is a static example that's demonstrate how to use lightgallery script, this works as expected. But I'm trying to make the script works adding elements dynamically, like this:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;animated-thumbs&quot; class=&quot;page-divs-middle&quot;&gt;
          &lt;!-- Elements here were dynamically added --&gt;
          
                    
          &lt;!-- Elements here were dynamically added --&gt;
      &lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function(){
      $('#animated-thumbs').lightGallery({
       thumbnail:true,
       selector: 'a',
       download:false,
       share:false,
       autoplayControls: false,
      });
     })
  &lt;/script&gt;
  </code></pre>
  <p>JavaScript</p>
  <pre class="lang-js prettyprint-override"><code>var target = $('#animated-thumbs');
  target.append('&lt;div class=&quot;col-md-3 col-xs-3 text-nowrap spacer-page-models fit pulsar&quot;&gt;&lt;a href=&quot;assets/img/01.jpg&quot;&gt;&lt;img class=&quot;img-responsive img-responsive-center cover&quot; src=&quot;assets/img/01.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;');
  </code></pre>
  <p>But it's not working because document was loaded previously. Someone can help me?</p>