Jump to content

Hide / show on mouseover


NLCJ

Recommended Posts

Hello,

I'm trying to hide and show something if it's shown (on mouseover) and vice versa when the mouse goes over the other div. However, it doesn't work (anymore). I've got no idea what happened. I changed something and it didn't work anymore (I tried CTRL + Z, didn't work).

function menutop(hide, show){
var hide = document.getElementById(hide);
if(hide.style.visibility == 'visible') { hide.style.visibility = 'hidden'; } 
if(hide.style.visibility == 'hidden') { hide.style.visibility = 'visible'; }

var show = document.getElementById(show);
if(show.style.visibility == 'visible') { show.style.visibility = 'hidden'; }
if(show.style.visibility == 'hidden') { show.style.visibility = 'visible'; } 
}

HTML code:

<img onmouseover="menutop('dmenu', 'amenu')" src="button.png" width="30" height="30" id="amenu" style="visibility: visible;" />
<div id="dmenu" onmouseout="menutop('amenu', 'dmenu')" style="visibility: hidden;">

 

Thank you,

Link to comment
Share on other sites

Nevermind, I've rewritten it:

<script type="text/javascript">
function show(box){
	document.getElementById(box).style.visibility="visible";
}
function hide(box){
	document.getElementById(box).style.visibility="hidden";
}
</script>

<img onmouseover="hide('amenu'); show('dmenu');" src="navigate.png" width="180" height="30" id="amenu" style="visibility: visible;" />
<div id="dmenu" onmouseout="hide('dmenu'); show('amenu');">

Works fine. ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.