使每个数组项成为一个单独的 link

Make each array item a separate link

我需要帮助从数组创建 links。我需要为数组

中的每个项目创建一个个性化的 link

代码如下:

caption: function(instance, item) {
    var caption, link, collectTags, tags;
    caption = $(this).data('caption');
    link = '<a href="' + item.src + '">Download image</a>';
    collectTags = $(this).parent().attr("class").split(' ');
    tags = $.each(function() {
        '<a href="' + collectTags + '">' + collectTags + '</a>'
    });
    return (caption ? caption + '<br />' : '') + link + '<br/>' + tags;
}

你的代码可能是这样的,你调用了 $.each 没有传递数组。

caption : function( instance, item ) {
    var caption, link, collectTags, tags;

    caption = $(this).data('caption');
    link    = '<a href="' + item.src + '">Download image</a>';
    collectTags =   $(this).parent().attr("class").split(' ');
    tags = $.map(collectTags,function(it){ return '<a href="' + it + '">'+ it +'</a>';});

    return (caption ? caption + '<br />' : '') + link + '<br/>' + tags;

}