[英]How to collect all the images from a folder
when you click on next then new images are loaded.But the new images are loaded from internet. 当您单击下一步时,将加载新图像。但是新图像是从Internet加载的。
In my app all the images are located in img/image folder and the image names are 1.jpg,hi.png etc 在我的应用程序中,所有图像都位于img / image文件夹中,图像名称分别为1.jpg,hi.png等
So how can I show the images when I click on next 所以当我单击下一步时如何显示图像
I thought i will modify var srcs = [ 'http://lorempixel.com/150/100/city', 'http://lorempixel.com/150/100/sports' ];
我以为我会修改
var srcs = [ 'http://lorempixel.com/150/100/city', 'http://lorempixel.com/150/100/sports' ];
with var srcs = [ 'img/image/1.jpg', 'img/image/hi.png' ];
使用
var srcs = [ 'img/image/1.jpg', 'img/image/hi.png' ];
But if I do this way then the problem will be I have to change var srcs
if I add a new image to the folder 但是,如果我这样做,那么问题是,如果我将新图像添加到文件夹,则必须更改
var srcs
For example If after a later time I add 3.jpg then I have to manually var srcs = [ 'img/image/1.jpg', 'img/image/hi.png','img/image/3.jpg' ];
例如,如果以后添加3.jpg,则必须手动
var srcs = [ 'img/image/1.jpg', 'img/image/hi.png','img/image/3.jpg' ];
Here an example that can help you, it's not optimal but works http://jsfiddle.net/PrVRq/ : 这是一个可以帮助您的示例,它不是最佳选择,但可以使用http://jsfiddle.net/PrVRq/ :
$('.images').on('loaded', function () {// load an image}
try to load the next image 尝试加载下一张图片
img.load(function () {
$('.images').append(img);
$('.images').trigger('loaded');
});
if the image is loaded trigger the loaded event to load another one. 如果图像已加载,则触发已加载事件以加载另一事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.