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 trialJason Whitaker
12,252 PointsLightbox console.log() not working. I have it typed exactly the same as the video.
//capture click event for link to image
$("#image-gallery a").click(function(event) {
event.preventDefault();
var href = $(this).attr("href");
console.log(href);
//show the overlay
//update overlay with image from link
//get alt attribute and set caption
});
6 Answers
Jason Whitaker
12,252 PointsI was able to fix this on my own. I can't remember what the problem was.
Jason Whitaker
12,252 PointsYes. The id for the gallery <ul> is "image-gallery".
Anthony Hernandez
7,365 PointsI realize this is getting a little dated, but in case it's unresolved, it's worth asking if you tried refreshing the view.
Lisa Cavern
2,027 PointsI had a similar problem where it seemed that the code wasn't working. I downloaded the workspace code and it works just fine from the files downloaded. Seems the issue for me was with the workspace.
Brian Mendez
7,734 PointsI recommend using the jquery alert() method. that way you will get an alert box that pops up showing the href string value, rather than trying to catch it in the browser. It is also less work as you don't have you check in the console. Obviously you would never do this in a production environment. But for training purposes. I like to use the alert method. :)
Marc Cook
4,610 PointsI was having the same problem so I tried Lisa Caverns and Brian Mendez's approach and unfortunately still didn't work. But it did help me find the problem, I forgot to add the }); at the end. ha Now It works in sublime and the alert pops up. Thanks guys!
leong shing chew
5,618 Pointsleong shing chew
5,618 PointsDid you give the < ul > element in your index.html the id of "image-gallery" ?
ul id="image-gallery"