Last active
May 24, 2018 09:11
-
-
Save solid-pixel/74116635b8d2906f163889dc1b7cebdc to your computer and use it in GitHub Desktop.
Hide element if tap/click outside of it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var menuIcon = $("#menu-icon-container"); | |
var menu = $('#menu'); | |
$(document).mouseup(function(e) { | |
if (!menuIcon.is(e.target) && menuIcon.has(e.target).length === 0 && menuIcon.hasClass('visible')) | |
{ | |
menu.hide(); | |
$(menuIcon).removeClass('visible'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment