Skip to content

Instantly share code, notes, and snippets.

@slaffko1
Created June 5, 2019 14:10
Show Gist options
  • Save slaffko1/e756cd8f82eb3d68f4476f65725b97df to your computer and use it in GitHub Desktop.
Save slaffko1/e756cd8f82eb3d68f4476f65725b97df to your computer and use it in GitHub Desktop.
const $menu = $('.dropdown');
$(document).mouseup(function (e) {
if (!$menu.is(e.target) // if the target of the click isn't the container...
&& $menu.has(e.target).length === 0) // ... nor a descendant of the container
{
$menu.removeClass('is-active');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment