0
我想要發生的是根據數組函數的結果提供不同的URL。 基本上,如果collectTags等於「教堂」或「音樂會」,則鏈接到A.com,否則鏈接到B.com。If..else基於數組函數結果的語句
這是我目前擁有的代碼:
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){ if(collectTags === "church"){ return '<a href="A.com' + it + '">'+ it +'</a>'} else{return '<a href="B.com' + it + '">'+ it +'</a>'};});
return (caption ? caption + '<br />' : '') + link + '<br/>' + tags.slice(1);
}
代碼有什麼問題? –
你還在嗎? –