How to hide ul by clicking off the menu or hovering the mouse off the menu? I tried but I did not succeed.
function aperfil(opthard){
if(document.getElementById(opthard).style.display== "none"){
document.getElementById(opthard).style.display = "block";}
else {document.getElementById(opthard).style.display = "none"}
}
<ul class="menup">
<li><a href="#"><img src="img/icones/perfil.png" width="27" height="22" alt="" onClick="aperfil('perfil');"/></a>
<ul id="perfil" style="display: none; border:1px solid #5589c4; background-color:#fff;">
<li><a href="/painel/alt_pass.php">Alterar Senha</a></li>
<li><a href="/painel/suporte.php">Suporte</a></li>
<li><a href="?go=sair">Sair</a></li>
</ul>
</li>
</ul>