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 trial

JavaScript jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 3

Why is my code not working? The image won't show in the overlay.

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

$overlay.append($image);

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

$("#imageGalery a").click(function(event){ event.preventDefault(); var imageLocation = $(this).attr("href"); $image.attr("src", imageLocation);

$overlay.show;

});

1 Answer

Looks to me like you have declared your overlay variable incorrectly.

Try this:

var $overlay = $("#overlay");

As an aside, you might want to look at the Markdown Cheatsheet link on this page for help with formatting your response.

If you put "" before your code, followed by the type of code you're writing (js in this case), then write your code, and close it all of with "" again it makes your code look like mine above.

Hope that helps, and good luck Don :-)

Sorry, one more thing. Don't forget to check the console in developers tools to check for any errors. Usually you'll find clues in there :-)