灯箱画廊连接起来

时间:2017-10-04 18:11:43

标签: javascript jquery html twitter-bootstrap-3 lightbox

我有3个div实现为lightbox gallery(3个独立的画廊),通过点击按钮触发。因此,div最初设置为display:none。 我试图通过以下方法点击按钮触发div,这只是正常工作。但是,所有3个画廊都在连接,即在打开的模式中,它显示其他div的图像。什么可能是错的?

脚本

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

1 个答案:

答案 0 :(得分:0)

使用过的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.

像:

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>
相关问题