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

CSS jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 3

Aaron Coursolle
Aaron Coursolle
18,014 Points

I'm confused with the theory of this use of hide?

I get most of the concepts of the video, and even know what hide does in general. But in the past we have performed show() and hide() on the same element.

This time we have the ability to click on different images, and each time it refreshes to show the updated image. This is what we want, obviously, but looking at the code, it wouldn't be something I would expect.

Basically, I'm wondering why it shows a new image, each time a new image is clicked, instead of showing the same image over and over again.

It would help to see the code you are referring to.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

It comes down to the 'this' selector. Each image has it own individual link (url), so when you click on one of the images, you are telling the program that 'this' is the one that you want the code to be executed on. So it really doesn't matter which one you click, the code will always show 'this' picture.

The 'hide' is just hiding the selected picture when you click the screen, telling the program you are done looking at that one and more-or-less 'resetting' the program.

Does that make sense? Jason

Sam Bass
Sam Bass
9,038 Points

Thank you! This really helps me understand.