0

I am using Jquery to shown and hide an overlay on the web page.

In my scenario, I am showing an overlay menu and currently close the overlay when an item within the menu is clicked (click event detected and then overlay closed).

$('#menu a').click(function(){ $('.overlay').hide(); });

Nice and simple!

I now have a requirement that I want to hide the overlay when anywhere on the screen is clicked other than the menu item (for convenience).

Here's an example:

enter image description here

$('.overlay').click(function(){  
  // pseudo code
  if (isDivClicked == false){
     $('.overlay').hide();
  }
});

Is there a way to see if the clicked area is the overlay but NOT the div shown (with the menu items).

Thanks in advance!

Rob
  • 6,819
  • 17
  • 71
  • 131

0 Answers0