I create an div and a list of anchor.
<div id="wrap">
<div id="box1"></div>
<div id="box2"></div>
<ul>
<li><a href=".." id="a1">text1</a></li>
<li><a href=".." id="a2">text2</a></li>
</ul>
</div>
my goal is when I mouseover the box1
the a1
will change the text color and when it mouseout it will back to the normal color.
I have try to do this using javascript but the problem is when I mouseover the one of the div box, for example I mouseover the box1
the a1
will change the color to red but when I mouseout, it will not change to blue, it will remain in red.
this mycode look like:
<script type="text/javascript">
function mouseoverBox1(){
var myPara = document.getElementById("a1");
myPara.style.color = "red";
}
function onmouseoutBox1(){
var myPara = document.getElementById("a1");
myPara.style.color = "blue";
}
function mouseoverBox21(){
var myPara = document.getElementById("a2");
myPara.style.color = "red";
}
function onmouseoutBox2(){
var myPara = document.getElementById("a2");
myPara.style.color = "blue";
}
</script>
<style>
a{color:red;}
a:hover{color:blue;}
.box{min-height: 180px;width: 220px;position: absolute;cursor: pointer;}
</style>
<div id="wrap">
<div class="box" id="box1" onmouseover="mouseoverBox1()" onmouseout="onmouseoutBox1()" ></div>
<div class="box" id="box2" onmouseover="mouseoverBox2()" onmouseout="onmouseoutBox2()"></div>
<ul>
<li><a href=".." id="a1">text1</a></li>
<li><a href=".." id="a2">text2</a></li>
</ul>
</div>
does anyone have an idea about my case?
any help will be appreciated. Thanks