Skip to content

Instantly share code, notes, and snippets.

@omariosouto
Last active October 27, 2015 16:48
Show Gist options
  • Save omariosouto/1822431693edd48db7e5 to your computer and use it in GitHub Desktop.
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
//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