这是“我的代码”,用于从Facebook拉取图片并显示它们。
但我想将图片环绕在
发布于 2013-06-03 09:10:00
可以使用jQuery wrap()函数将<a>标签放在<img>标签周围。只需使用appendTo()来获取新元素的实例,这样就可以对其进行包装()。
$.getJSON('http://graph.facebook.com/261512740659107/photos').then(function (response) {
// 0-8, 0 returns the largest available images, 8 the smallest
var imageIndex = 4;
var images = _(response.data)
.chain()
.pluck('images')
.pluck(imageIndex)
.value();
_(images).each(function (image) {
$($('<img>').attr({'src': image.source, 'height': 167, 'width': 167})).appendTo('#image-container').wrap('<a href="' + image.source + '" class="highslide" onclick="return hs.expand(this);" />');
});
});https://stackoverflow.com/questions/16888318
复制相似问题