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
https://forums.phpfreaks.com/topic/221525-hide-show-on-mouseover/
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. ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.