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 jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 2

Jana Ryndin
Jana Ryndin
7,161 Points

Why the screen does not turn black?

jQuery

var $overlay = $('<div id="overlay"></div'>);
$("body").append($overlay);
$("#imageGallery a").click(function(event){
  event.preventDefault();
  var href = $(this).attr("href");
  $overlay.show();
CSS
#overlay {
background:black;
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
}

4 Answers

Kevin Korte
Kevin Korte
28,109 Points

In addition to Sean Do's suggestion, you also did not close your click function at the end of the JS file. }) You're missing that.

Make those two correction, and you can verify your code works.

http://codepen.io/kevink/pen/MYMjRj

Sean Do
Sean Do
11,933 Points
var $overlay = $('<div id="overlay"></div'>);

The single quote is inside the div end tag.

Jana Ryndin
Jana Ryndin
7,161 Points

Thank you so much. After I posted I found it too. Wanted to let people know here but you were quicker. This was it, it works!

Jana Ryndin
Jana Ryndin
7,161 Points

I closed the click function but forgot to include it here in the post. Thanks.