Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLiz Pineda
2,254 PointsNot working
$(document).ready(function(){
$("button").click(function(){
$(this).removeClass("selected");
$(this).addClass("selected");
//url
var flickerAPI = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
//query string telling flicker we're making a jsonp request
//grab text from buttons
var animal = $(this).text();
//data in object form
var flickrOptions = {
tags: animal,
format: "json"
};
function displayPhotos(data) {
var photoHTML = '<ul>';
//loop through each of the photos from the flicker feed
$.each(data.items, function(i, photo) {
photoHTML += '<li class="grid-25 table-grid-50">';
//link to the flicker page for the image
photoHTML += '<a href="'+ photo.link +'" class="image">';
photoHTML += '<img src= "'+ photo.media.m + '"></a></li>';
});
photoHTML += '</ul>';
//add string to html of page
$('#photos').html(photoHTML);
}
$.getJSON(flickerAPI, flickrOptions, displayPhotos);
});
});
2 Answers
Sean T. Unwin
28,690 PointsOn line:
photoHTML += '<img src= "'+ photo.media.m + '"></a></li>';
There is a space between src=
and the double quotation marks. Remove the space:
photoHTML += '<img src="'+ photo.media.m + '"></a></li>';
A very subtle error, yet significant. :)
Liz Pineda
2,254 PointsThank you!!!
Sean T. Unwin
28,690 PointsSean T. Unwin
28,690 PointsI have edited your post so the code example displays properly. Please see this post regarding posting code - https://teamtreehouse.com/forum/posting-code-to-the-forum. :)