0
I have some HTML menus, which I show when a user clicks on these menus. I would like to hide these elements when the user clicks out of of the menu area.
How could I do that?
0
I have some HTML menus, which I show when a user clicks on these menus. I would like to hide these elements when the user clicks out of of the menu area.
How could I do that?
1
add a class . menus and then jquery:
$('body').on('click', function () { // Pega o clique
if (!$(this).hasClass('menus')) { //Se o objeto clicado não possuir a classe, então o clique foi fora dos menus
$('.menus').hide(); // esconde os menus
}
});
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.
event
onfocusout
active when you remove the focus of some element.– Máttheus Spoo