Bonesnap;10995922 wrote:This is my full HTML file minus the doctype.
<html lang="en">
<head>
<title>test</title>
<script>
function mover()
{
document.getElementById("visiblediv").style.display="block"
}
function mout()
{
document.getElementById("visiblediv").style.display="none"
}
</script>
</head>
<body>
<div id = "div1" onmouseover="mover()" onmouseout="mout()" style="background-color:#F00;">
Show the div
</div>
<div id = "visiblediv" style="border:1px dotted black">
This div is visible
</div>
</body>
</html>
Here's the problem I'm having now:
I am trying to implement a hide/show div, such that when you mouse over a div, another div pop's up below it. Here's what I have so far, but for some reason, only the first div set is working. That is when I mouse over div 1, div 2 shows up. So why isnt it working for divs 3,4 and 5,6? Here's my code:
HTML
<div >
<div id="showhide">
Line 1
</div>
<div id="visiblediv" style="display: none;">
Line 2
</div>
</div>
<div >
<div id="showhide">
Line 3
</div>
<div id="visiblediv" style="display: none;">
Line 4
</div>
</div>
<div >
<div id="showhide">
Line 5
</div>
<div id="visiblediv" style="display: none;">
Line 6
</div>
</div>
Javascript:
<script>
function mover(){
document.getElementById("visiblediv").style.display="block"
}
function mout() {
document.getElementById("visiblediv").style.display="none"
}
document.getElementById('showhide').onmouseover=mover;
document.getElementById('showhide').onmouseout=mout;
</script>
CSS:
#visiblediv {
visibility:visible;
border:1px dotted black;
}
Any ideas, as to why it's not working?