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.

CSS jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 4

Lightbox won't click away.

At the end of the course I got everything to look and act right. But when I click on an image, the lightbox pops up and no amount of clicking will make it go away. I don't understand what I've done to keep it from going away. Any Help?

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




$("#imageGallery a").click(function(event) { event.preventDefault(); var imageLocation = $(this).attr("href");

$image.attr("src", imageLocation);


var captionText = $(this).children("img").attr("alt"); $caption.text(captionText);


$overlay.click(function() { $overlay.hide


Post your code...it will be easier to see where you've gone wrong.

1 Answer

Hello Erik!

I think the problem is due to the missing () after .hide in your last function.

Instead of

$overlay.click(function() { $overlay.hide;})

you should write

$overlay.click(function() { $overlay.hide();})

Thank You!