简体   繁体   English

灯箱画廊已串联

[英]Lightbox gallery getting concatenated

I have 3 divs implemented as lightbox gallery (3 separate galleries), which are being triggered by clicking on a button. 我将3个div实施为灯箱画廊 (3个独立的画廊),它们是通过单击按钮触发的。 The div is thus set to display:none initially. 因此,div最初设置为display:none I've tried to trigger the div via button click by the below method, which is just working correctly. 我试图通过下面的方法通过单击按钮来触发div,该方法工作正常。 But, all the 3 galleries are getting concatenated ie in the modal that opens, its showing images of other divs. 但是,所有三个画廊都被连接起来,即在打开的模式中,显示了其他div的图像。 What could possibly be wrong? 有什么可能是错的吗?

Script 脚本

    $('#button1').on('click', function() {
         $('#div1').show();
    });
    $('#button2').on('click', function() {
         $('#div2').show();
    });
    $('#button3').on('click', function() {
         $('#div3').show();
    });

Used data-gallery="example-gallery" for every box. 每个框都使用data-gallery =“ example-gallery”。

like div1 boxes images should have  data-gallery="example-gallery1" attribute.
div2 boxes images should have data-gallery="example-gallery2" attribute.
div3 boxes images should have data-gallery="example-gallery3" attribute.

Like: 喜欢:

data-gallery="example-gallery1" 
data-gallery="example-gallery2"
data-gallery="example-gallery3"

 <a href="https://unsplash.it/1200/768.jpg?image=251" data-toggle="lightbox" data-gallery="example-gallery" class="col-sm-4">
                <img src="https://unsplash.it/600.jpg?image=251" class="img-fluid">
            </a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM