Created
January 11, 2020 20:28
-
-
Save guilhermemarconi/500677f4907e66866a3718d39cfad1a2 to your computer and use it in GitHub Desktop.
Interact with element when clicking outside of it
This file contains 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
const $wrapper = $('.my-element'); | |
$(document).on('click', e => { | |
if (!$wrapper.is(e.target) && $wrapper.has(e.target).length === 0) { | |
// do your stuff | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment