0
How to hide ul by clicking off the menu or hovering off the menu? I tried but failed.
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>
try using the jquery function
onmouseout
representing that you removed the mouse on top of the menu.– Marconi
@Marconi did the following I add <script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> and increased the script $(Document). ready(Function() { $("#profile").mouseout(Function() { Document.getElementById('profile').style.display = 'None'; }); }); correct?
– gezer
Change
mouseout
foronmouseout
. Hover mouse image . http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onmouseover– Marconi
for me became more suitable <script>Function aperfil(opthard){ if(Document.getElementById(opthard).style.display== "None"){ Document.getElementById(opthard).style.display = "block";} } <! -- hide the menu if you hover the mouse outside requires jquery.min-> $(Document). ready(Function() { $("#profile").mouseover(Function() { Document.getElementById('profile').style.display = 'block'; }); $("#profile").mouseout(Function() { Document.getElementById('profile').style.display = 'None'; }); }); </script>
– gezer
Did you get it? I’m going to post an answer, just so it doesn’t get vague.
– Marconi