Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Baur Alzhanov
Baur Alzhanov
7,028 Points

After included caption code, my slideshow have been working

Please, help me. I check my code twice. Before caption.text, my overlay slide had worked. And after including new code, my overlay and caption don't working. What I need to do? //Problem: User when clicking on image goes to a dead end //Solution: Create an overlay with the large image - Lightbox

var $overlay = $('<div id="overlay"></div>'); var $image = $("<img>"); var $caption = $("<p></p>");

//An image to overlay $overlay.append($image);

//A caption to overlay $olerlay.append($caption);

//Add overlay $("body").append($overlay);

//A caption

//Capture the click event on a link to an image $("#imageGallery a").click(function(event){ event.preventDefault(); var imageLocation = $(this).attr("href");

//Update overlay with the image linked in the link $image.attr("src", imageLocation);

//Show the overlay $overlay.show();

//Get child's alt attribute and set caption var captionText = $(this).children("img").attr("alt"); $caption.text(captionText); });

//When overlay is clicked $overlay.click(function(){ //Hide the overlay $overlay.hide(); });

Steven Parker
Steven Parker
215,940 Points

Can you provide a link to a workspace snapshot?

1 Answer

Baur Alzhanov
Baur Alzhanov
7,028 Points

Steven Parker and Sandro Das Neves thank you. I was solve my problem.