Skip to content

Instantly share code, notes, and snippets.

@fabriziofeitosa
Last active September 9, 2020 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabriziofeitosa/725135bef851f563311d9f74c291e885 to your computer and use it in GitHub Desktop.
Save fabriziofeitosa/725135bef851f563311d9f74c291e885 to your computer and use it in GitHub Desktop.
(JS) (jQuery) Click fora da área
$(function () {
$("body").on("click", function (e) {
// Defina o alvo | Ex.: ".notificacao,.boxPerfil" | Não faz nada se for o alvo.
if ($(e.target).closest(".notificacao,.boxPerfil").length) return;
// O que deve ser feito caso não seja o alvo?
console.log("Você clicou fora do alvo!");
document.getElementById("optNotif").checked = false;
document.getElementById("optMenu").checked = false;
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment