Last active
October 27, 2015 16:48
-
-
Save omariosouto/1822431693edd48db7e5 to your computer and use it in GitHub Desktop.
EN - Click out element remove class | PT - Clique fora de um elemento e remova uma class
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
//You can use it for make an event like: "Click out of element and remove a class (for example)." | |
// Você pode usar isso para fazer um evento como: "Clique fora do elemento e remova uma class (por exempo)." | |
$(document).mouseup(function (e) | |
{ | |
var container = $("YOUR ELEMENT"); | |
if (!container.is(e.target) // if the target of the click isn't the container... | |
&& container.has(e.target).length === 0) // ... nor a descendant of the container | |
{ | |
container.hide(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment