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

I don't understand why the console gets involved.

Why do we use the console at all?

//1. Capture the link event on a link to an image $("#imageGallery a").click(function(){ var href = $(this).attr("href"); console.log(href);

1 Answer

Steven Parker
Steven Parker
231,275 Points

The console can be a useful testing and/or teaching aid.

The console can be very handy for observing things happening in a program for debugging problems or teaching.

Here it is being used as a teaching aid to display the value that the previous line of code acquires from the DOM. As you suspected, this has no effect on functionality of the lightbox itself and only serves to convey an understanding of how it works.

Ah ok, so we can just use it to just see what's going on? Is it necessary to keep? Thank you!

Steven Parker
Steven Parker
231,275 Points

As I said, in this particular case it is purely a teaching aid. Removing it will not affect the functionality of the light box.

Brandon Moore
Brandon Moore
10,266 Points

I personally took it as to make sure when we do the overlay the href is successfully having the clicked item passed on to it.