不会动,代码一样,就是不会动
<!DOCTYPE html>
<html>
<head>
<title>huoqu</title>
</head>
<style type="text/css">
body,ul,li{
margin: 0;
padding: 0;
}
ul,li{
list-style: none;
}
ul li{
width: 200px;
height: 100px;
background: blue;
margin-bottom: 20px;
}
</style>
<script type="text/javascript">
window.onload=function(){
var ai=document.getElementsByTagName('li');
for(var i=0;i<ali.length;i++){
ai[i].timer=null;
ai[i].onmouseover=function(){
starmove(this,400);
}
ai[i].onmouseout=function{
starmove(this,200);
}
}
}
function starmove(obj,target){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=(target-obj.offsetWidth)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.offsetWidth==target){
clearInterval(obj.timer);
}
else{
obj.style.width=obj.offsetWidth+speed+'px';
}
},30);
}
</script>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>