Pulling Flickr image title?
My javascript is pulling single Flickr images randomly on each re开发者_如何转开发fresh. I would like to also display the image title (preferably on rollover) too. Been looking for hours on how to do this but not getting anywhere (don't really know js).
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=63338473@N03&tags=webhomeug&format=json&jsoncallback=?", displayImages);
var count = 0;
var htmlString = "<ul>";
function displayImages(data){
if(count <= 0){
var ranNum = Math.floor(Math.random()*($(data.items).size()));
var img = (data.items[ranNum].media.m).replace("_m.jpg", "_b.jpg");
var link = data.items[ranNum].link;
var title = data.items[ranNum].title;
htmlString += '<img src="' + img + '" alt="' + title + '" title="' + title + '" class=vtip"/>';
count++;
displayImages(data);
}else{
htmlString += '</ul>'
$('#images').html(htmlString);
}
}
$("selectYourPhoto").attr("title");
Thanks for pointing me in the right direction.
The suggested code wasn't working for me, but after looking into the attr method I found this works perfectly...
$("div").text($("img").attr("title"));
Thanks again!
精彩评论