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 trialAman Mender
11,197 PointsMy screen does not turn black
//Solution: Create a overlay with the large image - lightbox
var $overlay = $('<div id="overlay"></div>');
// Add overlay
$("body").append($overlay);
// An image
// A caption
//1. Capture the click event on a link to an image
$("#image-Gallery a").click(function(event){
event.preventDefault();
var href = $(this).attr("href");
console.log(href);
//1.1 Show the overlay
$overlay.show();
//1.2 Update overlay with the image linked in the link
//1.3 Get child's alt attribute and set caption
}
);
#overlay {
background: rgba(0,0,0,0.7);
width: 100%;
height: 100%;
top: 0;
left: 0;
}
1 Answer
Joe Bruno
35,909 PointsHello Aman,
Looks like your issue may have been your css selector of "#imageGallery a". You have "#image-Gallery a" , with a hyphen, written above. If that is the case and not merely a typo in the forum, that would be the issue. Also, in your css, you need another declaration of "display: none;". The black div should be hidden by default and then shown by jQuery. Without the display none, it should have been visible as soon as the append method ran.
...
//Capture the click event on a link to an image
$("#imageGallery a").click(function(event){
event.preventDefault();
var href = $(this).attr("href");
$overlay.show();
//Show the overlay.
//Update overlay with the image linked in the link
//Get child's alt attribute and set caption
});
Best of luck!