lightbox 2: how to add dynamically images via javascript

后端 未结 2 891
时光说笑
时光说笑 2021-01-23 02:11

I\'m having trouble attempting to dynamically add images, since lightbox2 (by lokesh dakar) is initialized after document load by existent html

2条回答
  •  旧巷少年郎
    2021-01-23 02:12

    To add existing img tags to be lightboxified on their own (without gallery functionality) one could use something like:

    $('img')
        .wrap(function(index) {
            return '';
        });
    

    Just add it BEFORE inserting the lightbox.js

提交回复
热议问题