Last active
December 22, 2015 19:49
-
-
Save sagarjadhav/6522072 to your computer and use it in GitHub Desktop.
jQuery to hide a DIV when the user clicks 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
$(document).mouseup(function (e) { | |
var container = $("YOUR CONTAINER SELECTOR"); | |
/* if the target of the click isn't the container */ | |
/* Nor a descendant of the container */ | |
if ( !container.is(e.target) && container.has(e.target).length === 0) { | |
container.hide(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment