提取 Flickr 图片标题?
我的 javascript 在每次刷新时随机提取单个 Flickr 图像。我还想显示图像标题(最好是在翻转时)。一直在寻找如何做到这一点的几个小时,但没有取得任何成果(真的不知道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);
}
}
My javascript is pulling single Flickr images randomly on each refresh. 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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢您为我指明了正确的方向。
建议的代码对我不起作用,但在研究 attr 方法后,我发现它完美地工作......
再次感谢!
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...
Thanks again!