Javascript Lightgallery哈希插件中的多个库?

Javascript Lightgallery哈希插件中的多个库?,javascript,jquery,html,gallery,lightgallery,Javascript,Jquery,Html,Gallery,Lightgallery,我无法运行插件Lightgallery哈希。我的愿望是在同一页上有两个图库,点击一个按钮就会显示另一个图库。如果我没有弄错的话,插件应该这样做 我添加了这个HTML结构: <div id="hash"> <a href="img/img_port/reportage/img-1.jpg"> <img src="img/img_port/reportage/thumb-1.jpg" /> </a> <a href="img/img_po

我无法运行插件Lightgallery哈希。我的愿望是在同一页上有两个图库,点击一个按钮就会显示另一个图库。如果我没有弄错的话,插件应该这样做

我添加了这个HTML结构:

<div id="hash">
<a href="img/img_port/reportage/img-1.jpg">
    <img src="img/img_port/reportage/thumb-1.jpg" />
</a>
<a href="img/img_port/reportage/img-2.jpg">
    <img src="img/img_port/reportage/thumb-2.jpg" />
</a>
<a href="img/img_port/reportage/img-3.jpg">
    <img src="img/img_port/reportage/thumb-3.jpg" />
</a>
<a href="img/img_port/reportage/img-4.jpg">
    <img src="img/img_port/reportage/thumb-4.jpg" />
</a>


这个Javascript:

<script type="text/javascript">
        $(document).ready(function() {
            $("#hash").lightGallery({
                download: false,
                counter: false,
                hash: true;
                galleryId: 1
                });
            $("#hash2").lightGallery({
                download: false,
                counter: false,
                hash: true;
                galleryId: 2
                    });
            });
    </script>

$(文档).ready(函数(){
$(“#hash”).lightGallery({
下载:错,
柜台:错,
哈希:true;
帆船类:1
});
$(“#hash2”)。lightGallery({
下载:错,
柜台:错,
哈希:true;
帆船类:2
});
});
这是正确的还是有问题?


<script type="text/javascript">
    $(document).ready(function() {
        $("#hash").lightGallery({
            download: false,
            counter: false,
            hash: true,  /*Here is the error.*/
            galleryId: 1
            });
        $("#hash2").lightGallery({
            download: false,
            counter: false,
            hash: true,/*Here is the error.*/
            galleryId: 2
                });
        });
</script>
$(文档).ready(函数(){ $(“#hash”).lightGallery({ 下载:错, 柜台:错, hash:true,/*这里是错误*/ 帆船类:1 }); $(“#hash2”)。lightGallery({ 下载:错, 柜台:错, hash:true,/*这里是错误*/ 帆船类:2 }); });
首先,您应该通过类而不是id来标识您的库


然后使用特定类循环每个类并启动lightGallery()

$('.lightgallery')。每个(函数(索引){
$('#'+this.id).lightGallery({
分享:错,
加列利德:索引
});
})

问题出在哪里?对我来说似乎是正确的。请确保在此脚本之前加载了所有库。问题是,我发现两个库一个在另一个之上,而不仅仅是提供解决问题的代码。还提供了一个小的解释为什么它解决了这个问题以及如何解决。我刚刚删除了“;”并添加了“,”来分隔函数中的参数。
<script type="text/javascript">
    $(document).ready(function() {
        $("#hash").lightGallery({
            download: false,
            counter: false,
            hash: true,  /*Here is the error.*/
            galleryId: 1
            });
        $("#hash2").lightGallery({
            download: false,
            counter: false,
            hash: true,/*Here is the error.*/
            galleryId: 2
                });
        });
</script>