<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{padding: 0px;margin: 0px;}
ul{list-style: none;}
.wrap{width: 500px;height: 500px;border: 1px solid red;margin: 60px 0px 0px 60px;}
ul{margin-left: 20px;margin-top: 30px; border: 1px dashed brown;
position: relative;
}
li{width:50px;height: 50px;background: #e6e9ea;margin-top: 20px;}
li>div{background: #8ce3fc;width: 150px;height: 190px;
position: absolute;
top: 20px;
left: 50px;
}
/*#b>div{background: #8ce3fc;width: 150px;height: 190px;
position: absolute;
top: 30px;
left: 50px;
}*/
li:hover{background: #8ce3fc;}
.hid{display: none;}
.show{display: block;}
</style>
</head>
<body>
<div class="wrap">
<ul>
<li id="a" οnmοuseοver="over('a')" οnmοuseοut="out('a')"> <!--对于over(ID) 函数,在调用时传入id的时候,只能用 ''单引号,""双引号不行-->
<span>1</span>
<div id="ad" class="hid">
hello_1
</div>
</li>
<li id="b" οnmοuseοver="over('b')" οnmοuseοut="out('b')">
<span>2</span>
<div id="bd" class="hid">
hello_2
</div>
</li>
<li id="c" οnmοuseοver="over('c')" οnmοuseοut="out('c')">
<span>3</span>
<div id="cd" class="hid">
hello_3
</div>
</li>
</ul>
</div>
<script type="text/javascript">
function over(ID){
var o = document.getElementById(ID).getElementsByTagName("div")[0].className="show";
}
function out(ID){
var o = document.getElementById(ID).getElementsByTagName("div")[0].className="hid";
}
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{padding: 0px;margin: 0px;}
ul{list-style: none;}
.wrap{width: 500px;height: 500px;border: 1px solid red;margin: 60px 0px 0px 60px;}
ul{margin-left: 20px;margin-top: 30px; border: 1px dashed brown;
position: relative;
}
li{width:50px;height: 50px;background: #e6e9ea;margin-top: 20px;}
li>div{background: #8ce3fc;width: 150px;height: 190px;
position: absolute;
top: 20px;
left: 50px;
}
/*#b>div{background: #8ce3fc;width: 150px;height: 190px;
position: absolute;
top: 30px;
left: 50px;
}*/
li:hover{background: #8ce3fc;}
.hid{display: none;}
.show{display: block;}
</style>
</head>
<body>
<div class="wrap">
<ul>
<li id="a" οnmοuseοver="over('a')" οnmοuseοut="out('a')"> <!--对于over(ID) 函数,在调用时传入id的时候,只能用 ''单引号,""双引号不行-->
<span>1</span>
<div id="ad" class="hid">
hello_1
</div>
</li>
<li id="b" οnmοuseοver="over('b')" οnmοuseοut="out('b')">
<span>2</span>
<div id="bd" class="hid">
hello_2
</div>
</li>
<li id="c" οnmοuseοver="over('c')" οnmοuseοut="out('c')">
<span>3</span>
<div id="cd" class="hid">
hello_3
</div>
</li>
</ul>
</div>
<script type="text/javascript">
function over(ID){
var o = document.getElementById(ID).getElementsByTagName("div")[0].className="show";
}
function out(ID){
var o = document.getElementById(ID).getElementsByTagName("div")[0].className="hid";
}
</script>
</body>
</html>