I have a window that opens when I click on an element, blz. But how can I do to, by clicking OUTSIDE this window, it closes?
I have a window that opens when I click on an element, blz. But how can I do to, by clicking OUTSIDE this window, it closes?
Treat this as 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()
}
});
I think there should be some kind of mask behind that content, right?
Do something like this:
$("#mascara").click( function(e){
e.preventDefault();
$(".sua-tela").fadeOut(function(){
$(this).hide();
$("#mascara").hide();
});
});