我的获取到的对象一直是window 代码如下 移入就会报错
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>JS动画2</title>
<style type="text/css">
ul li {
list-style: none;
width: 200px;
height: 100px;
background: yellow;
margin-bottom: 20px;
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</body>
<script type="text/javascript">
window.onload=function() {
var lis=document.getElementsByTagName("li");
for(var i=0;i<lis.length;i++){
lis[i]=onmouseover=function(){
Move(this,400);
}
lis[i]=onmouseover=function(){
Move(this,200);
}
}
}
var timer=null;
function Move(tar,aim) {
clearInterval(timer);
timer=setInterval(function(){
var sp=(aim-tar.offsetWidth)/8;
sp=sp>0?Math.ceil(sp):Math.floor(sp);
if(tar.offsetWidth==aim){
clearInterval(timer);
}else{
tar.offsetWidth=tar.style.width+sp+"px";
}
},10);
}
</script>
</html>