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 trialhasinaakhter
8,540 PointsMy overlay is not working!
Hello
I have written the same codes as the Instructor yet my overlay is not working. When I click on each image instead of showing the image as overlay (on other images,) the clicked image (with a black background) is appearing just under the image gallery. Please help me fix this problem. Here is the codes:
var $overlay = $('<div id="overlay"></div>'); var $image = $("<img>"); var $caption = $('<p></p>');
$overlay.append($image);
$("body").append($overlay);
$overlay.append($caption);
$("#imageGallery a").click(function(event){ event.preventDefault(); var imageLocation = $(this).attr("href");//rename href to imagelocation $image.attr("src", imageLocation);
$overlay.show();
var captionText = $(this).children("img").attr("alt"); $caption.text(captionText);
});
$overlay.click(function(){ $overlay.hide();
});
sid Malhotra
635 Pointssid Malhotra
635 Pointswill u please fork your workspace snapshot link for us to see the problem by executing the code