안녕하세요 저는 flickr 갤러리가 있고 div '갤러리'에서 사진을로드하고 싶지만 'data-category'에 정의 된 지정된 태그가있는 두 개의 첫 번째 사진 만로드해야합니다 그 div에. flickr gallery 지정된 태그에서 사진을로드하는 중
<div data-category="clouds" class="gallery"></div>
<div data-category="mount" class="gallery"></div>
JS :
나는 HTML을
$('.gallery').each(function(index) {
var dataCategory = $(this).attr('data-category');
(function() {
var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$.getJSON(flickerAPI, {
tags : dataCategory,
tagmode : "any",
format : "json"
}).done(function(data) {
$.each(data.items, function(i, item) {
var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");
$("<img/>").attr("src", sourceSquare).appendTo(".gallery");
if (i === 1) {
return false;
}
});
});
})();
});
내가 지금은 모든 '갤러리'div의에 지정된 모든 태그에서 처음 두 사진을로드하는 것입니다이 문제. '갤러리'에는 두 장의 사진을로드해야하지만 '데이터 카테고리'에 지정된 태그 만 사용해야합니다.
가 바로-호출 익명 함수 무엇입니까? – nnnnnn
@nnnnnn'(function() {security})();'hahahaha –