배열 기능 결과에 따라 다른 URL을 제공하려고합니다. 기본적으로 collectTags가 "church"또는 "concert"와 같으면 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);
}
코드에 어떤 문제가 있습니까? –
여기에 아직도 있습니까? –