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

Exercise Question

I had a question about hiding this overlay at the very end of this tutorial. I noticed the teacher used the variable "$overlay" to hide the overlay. So he used $overlay.hide(). I was following along and entered $('#overlay').hide() as I'm used to using jquery with divs on the DOM. When I use my way, however, it no longer works. But if I switch it back to using the variable it works. What is the reason for this?

1 Answer

Hi John,

It would be more efficient to use the variable $overlay but what you have tried should work also.

I tried it and it works for me.

Did you have your code like this?

$overlay.click(function(){
  //Hide the overlay
  //$overlay.hide();
  $('#overlay').hide();
});