慕斯卡8315334
2016-08-08 20:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#nav{
width: 200px;
height: 250px;
background: #cccccc;
}
#nav-a{
width: 100px;
height: 200px;
background: #56c;
}
li{
height: 20px;
width: 20px;
background: #000000;
border: 1px solid #ffffff;
}
</style>
<script type="text/javascript">
window.onload=function() {
var nav = document.getElementById('nav').getElementsByTagName('li');
for(var i=0;i<nav.length;i++)
nav[i].onmouseover = function () {
changea();
}
nav[i].onmouseout=function () {
changeb()
}
};
function changea() {
var aNav=document.getElementById('nav-a');
aNav.style.display='none';
}
function changeb() {
var aNav=document.getElementById('nav-a');
aNav.style.display='block';
}
</script>
</head>
<body>
<div id="nav">
<ul>
<li></li>
<li></li>
</ul>
</div>
<div id="nav-a"></div>
</body>
</html>
for循环下少了{}把后面这段包裹起来:
nav[i].onmouseover = function () {
changea();
}
nav[i].onmouseout=function () {
changeb()
}
JS动画效果
113925 学习 · 1443 问题
相似问题