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


jQuery Basics, Stage 3, Quiz not parsing

I am doing jQuery Basics, and I am on Creating a LightBox. I was presented with a the second question On line 7, set href to be the value of the href attribute of the clicked link.

The first part was simple, but then the second part was harder. It kept giving me Oops! It looks like Task 1 is no longer passing.

Here is the code wich I am stuck on:

//Problem: User when clicking on image goes to a dead end
//Solution: Create an overlay with the large image - Lightbox

//1. Capture the click event on a link to an image
$("#imageGallery a").click(function(event){
  var href = $(this);
  //1.1 Show the overlay.
  //1.2 Update overlay with the image linked in the link
  //1.3 Get child's alt attribute and set caption

//2. Add overlay
  //2.1 An image
  //2.2 A caption
//3. When overlay is clicked
  //3.1 Hide the overlay

I am really stuck on this part, it says that I have to set the clicked href to href. Look here

$("#imageGallery a").click(function(event){
  var href = $(this);

This has stumped me, I hope you can answer!

1 Answer

You just have to move your .attr("href") down a line, so it's being called on the variable "href".

That will make the variable "href" equal to the href attribute of #imageGallery a, AKA the URL of the picture you click.

Hope that works for you!

Thanks Bryan! Helped me a lot!!