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 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,148 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.