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
rr21
6,398 PointsJquery Lightbox not working
Hi,
So I'm having some issues with Jquery, I've successfully managed to get my overlay to fade in and out when clicking but I can't get the image to show with the overlay. If anyone could be of assistance that would be great! Thanks in advance!
Below is a snippet of my code
var $overlay = $('<div id="overlay"></div>');
var $image = $('<div id"img-overlay"</div>');
$('body').append($overlay);
$('.box').click(function(event){
$($overlay).fadeIn();
$($image).show();
})
$overlay.click(function(){
$overlay.fadeOut();
$('#overlay .btn').hide();
})
});
<div class="img-gallery">
<div class="wrap">
<h1>Gallery</h1>
<h2>Collection of images of Phoenix Yoga</h2>
<div class="box">
<div class="inner-content">
<div class="img"><img class="img-overlay" src="img/yoga-7.png">
<div class="overlay">
<p class="overlay-text"></p>
</div>
</div>
</div>
</div>
Marco Koopman
5,290 PointsMarco Koopman
5,290 PointsHey!
First try to fix var $image = $('<div id"img-overlay"</div>'); to var $image = $('<div id"img-overlay"></div>');
You forgot a > there!