Skip to content

Instantly share code, notes, and snippets.

@Bewitchedyegor
Created October 12, 2017 13:13
Show Gist options
  • Save Bewitchedyegor/a62eae2969821b3eba686b6d13512baf to your computer and use it in GitHub Desktop.
Save Bewitchedyegor/a62eae2969821b3eba686b6d13512baf to your computer and use it in GitHub Desktop.
Closing any container when clicking outside of it
$(document).mouseup(function(e) {
let container = $(".js-postOptionsMenu"); //insert container selector, multiple selectors for different containers will work fine
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.fadeOut();//you can replace .fadeOut() with any other way to hide your container
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment