0
I have a window that opens when clicking on an element, blz. But how can I do to, when clicking OUTSIDE of that window, it closes?
0
I have a window that opens when clicking on an element, blz. But how can I do to, when clicking OUTSIDE of that window, it closes?
4
Treat it to an ancestor of the element you want to hide:
$(document).on('click', function(e){
// verifique se o clique veio de dentro da sua janela.
// para isso use e.target (a origem do clique).
// se não tiver vindo da sua janela, feche a janela.
// exemplo:
if(!$('#janela').contains(e.target)) {
$('#janela').close()
}
});
Just to contextualize the topic, with jQuery it would be through jQuery.on().
0
I believe you must have some sort of mask behind that content of yours, correct?
Do something like that:
$("#mascara").click( function(e){
e.preventDefault();
$(".sua-tela").fadeOut(function(){
$(this).hide();
$("#mascara").hide();
});
});
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
I got it guys. I just needed to know how I could sweep all my DOM behind a class and display it/hide it.
– dsantoro
I suggest posting your answer below, as an answer, so you can help other people with the same problem. If you want, you can even mark your own answer as accepted. For details see http://meta.pt.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-reply
– bfavaretto