我想从Javascript数组中加载一些图像但是无法加载图像。有人可以看看我的代码吗?
谢谢
apache_get_modules

var works = [
{
title: "First Project",
pic: "https://www.petfinder.com/wp-content/uploads/2012/09/Blog-Kitty-Cam-solo.jpg"
},
{
title: "Second Project",
pic: "http://www.animal-photography.com/thumbs/red_tabby_long_hair_kitten_~AP-0UJFTC-TH.jpg"
},
{
title: "Third Project",
pic: "http://www.animal-photography.com/thumbs/silver_tabby_kittens~AP-0JO6Y9-TH.jpg"
},
{
title: "Fourth Project",
pic: "http://www.animal-photography.com/thumbs/silver_tabby_kitten_looking_up~AP-0DLVMB-TH.jpg"
}
];

答案 0 :(得分:1)
我已经纠正了代码中的一些内容:
JS代码: //作品
for(var i = 0; i < works.length; ++i) {
//script for array goes here
$('#work1').append('<div class="col-xs-6 col-md-6 col-md-3">' +
'<a href="#" class="work-img">' +
'<img class="img-responsive" src="' + works[i].pic + '">' +
'<span class="info"><p class="proj-title">Title:</p>' + works[i].title + '</span>' +
'</a>' +
'</div>'
);//append closes
}
for
循环未关闭且元素串联错误。除了每张图片的标题之外,它的打印效果也不错。