为什么我的毫无反应呢??半天都没找出来。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JS多物体运动动画</title>
<style type="text/css">
ul,li{
list-style:none;}
ul li{
width:200px;
height:100px;
background:yellow;
margin-bottom:20px;}
</style>
<script type="text/avascript">
window.onload=function(){
var aLi=document.getElementsByTagName("li");//aLi为数组
for(var i=0;i<aLi.length;i++)
{
aLi.time=null;
aLi[i].onmouseover=function(){
startMove(this,400);
}
aLi[i].onmouseout=function(){
startMove(this,200);
}
}
}
aLi[i].timer=null;
function startMove(obj,terget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=(terget-obj.offsetWidth)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.offsetWidth==terget){clearInterval(obj.timer);}
else{obj.style.width=obj.offsetWidth+speed+"px";
},30)
}
</script>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>