Good Night, well I'm doing some tests and I came across this problem, I'm a beginner in Js, and I was able to make the div appear when I clicked on the "div" button, and I tried to make it disappear when clicking on the body, it worked out however when I click again on the "appear div" it does not appear again. Please help me.
$( ".btn-configuracao" ).click(function() {
$( '#menu-config' ).show();
});
$("#menu-config").mouseleave(function(){
$('body').click(function(){
$("#menu-config").hide();
});
});
#menu-config{
width: 270px;
height: 300px;
position: fixed;
background-color: white;
box-shadow: 1px 1px 7px grey;
right: 50px;
top: 60px;
color: #0099e5;
z-index: 9999;
transition: all .4s;
display: none;
}
#menu-config legend{
background-color: #0099e5;
color: white;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 5px;
display: flex;
}
#menu-config legend img{
width: 24px;
height: 24px;
margin-left: 5px;
}
#menu-config legend p{
color: white;
margin-top: 4px;
margin-left: 6px;
}
.tema{
display: flex;
margin-top: 10px;
margin-left: 10px;
}
.tema img{
width: 16px;
height: 16px;
margin-right: 6px;
margin-top: 2px;
margin-left: 5px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="Estilos.css">
<script
src="https://code.jquery.com/jquery-3.3.1.js"></script></head><body><liclass="btn-configuracao"><a href="#">aparecer div</a></li>
<div id="menu-config">
<legend> <img class='imgConfigMenor' src="../Imagens/none.png" alt=""> <p>Configurações</p></legend>
<div class="tema">
<img class='imgLua' src="../Imagens/none.png" alt="">
</div>
</div>
</body>
</html>