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 1

Lightbox 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                         
 });
leong shing chew
leong shing chew
5,618 Points

Did you give the < ul > element in your index.html the id of "image-gallery" ?

ul id="image-gallery"

6 Answers

I was able to fix this on my own. I can't remember what the problem was.

Yes. The id for the gallery <ul> is "image-gallery".

Anthony Hernandez
Anthony Hernandez
7,365 Points

I 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
Lisa Cavern
2,027 Points

I 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
Brian Mendez
7,734 Points

I 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
Marc Cook
4,610 Points

I 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!