Skip to content

Instantly share code, notes, and snippets.

@codekipple
Created November 18, 2014 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codekipple/45c785e738a7e3ea0d5e to your computer and use it in GitHub Desktop.
Save codekipple/45c785e738a7e3ea0d5e to your computer and use it in GitHub Desktop.
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
@codekipple
Copy link
Author

Consider binding and unbinding this so it only listens when the pop is open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment