gpt4 book ai didi

javascript - lightgallery 无法正常工作

转载 作者:行者123 更新时间:2023-11-28 06:41:04 25 4
gpt4 key购买 nike

我正在使用 localhost xampp 进行练习。我已经实现了一个 lightgallery 以使用 js 显示我的图像文件夹中的图像,但 lightgallery 没有将图像显示为 gallaery..

这里我摘录了我的代码....

$(element).lightgallery();

不起作用...其中元素是 span 标记的类,此类和 span 由 js ( var container ="<span> <bla> <bl>image<bl/> </bla></span>"; $("#this_div_id_in_html_page_or_this_div_of_html_page").append(container); ) 创建

$(document).ready(function() {
var imagesarray= [];
imagesarray[0] = "http://www.planwallpaper.com/static/images/Winter-Tiger-Wild-Cat-Images.jpg";
imagesarray[1] = "http://www.gettyimages.ca/gi-resources/images/Homepage/Category-Creative/UK/UK_Creative_462809583.jpg";
imagesarray[2] = "http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg";
imagesarray[3] = "http://i765.photobucket.com/albums/xx291/just-meller/national%20geografic/Birds-national-geographic-6873734-1600-1200.jpg";
imagesarray[4] = "http://www.gettyimages.com/gi-resources/images/CreativeImages/Hero-527920799.jpg";

var hiddenimages = "",albumcover;
$("#appendnewcontainer").click(function (){
/*for (var i = 0; i < imagesarray.length; i++) {
imagepath = imagesarray[i];
hiddenimages += "<a class='hidimage' href=" + imagepath + "><img src=" + imagepath + "/></a>"
}*/

var glryPostContainer = "<span class='container'>" +
"<span class='imagecontiner'>" +
"<a class='dfed' href=" + imagesarray[1] + ">" +
"<img src='" + imagesarray[1] + "' class='_34'/>" +
"</a>" +
"</span>" +
"</span>";

$("#fotoappendarea").append(glryPostContainer);
});
$(".imagecontiner").lightGallery();
});
#fotoappendarea {
box-sizing: border-box;
display: inline-block;
width: 550px;
min-height: 100px;
max-height: 450px;
margin: 10px 0px;
padding: 5px;
background-color: #fff;
border-radius: 7px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.8/css/lightgallery.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.8/js/lightgallery-all.min.js"></script>
<div id="appendnewcontainer"> Click me To make new album</div>
<div id="fotoappendarea"></div>

最佳答案

我没有发现任何问题,即使您的演示也能正常运行。但正如你在片段中所写的那样,它是

$(".imagecontiner").lightGallery();

不是

$(".imagecontiner").lightgallery();

注意驼峰式

WORKING COPY

关于javascript - lightgallery 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34294108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com