Load one random flickr image & append to div

前端 未结 5 898
别跟我提以往
别跟我提以往 2021-02-10 02:33

I\'m basically trying to load in one random flickr image taken from a specific user and specific set which then gets displayed within a div with the id of \'flickr-wrap\'. I\'m

5条回答
  •  旧巷少年郎
    2021-02-10 02:42

    data.items is the array of your images, so just get the first one and don't iterate over the array.

    Instead of

    $.each(data.items, function(i,item){...}
    

    do

    $("").attr({src: data.items[0].media.m.replace('_m.','.')}).appendTo("#flickr-wrap");
    

提交回复
热议问题