怎么没效果呢?
!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
ul{
list-style: none;
}
ul li{
width:200px;
height:100px;
background: #F33;
margin-bottom: 20px;
}
</style>
<script type="text/javascript">
window.onload=function(){
var an=document.getElementsByTagName("li");
for(var i=0;i<an.length;i++){
an[i].timer=null;
an[i].onmouseover=function(){
sart2(this,400);
}
an[i].onmouseout=function(){
start2(this,200);
}
}
}
//var timer=null;
function start2(sh,target){
clearInterval(sh.timer);
sh.timer=setInterval(function(){
var speed=(target-sh.offsetWidth)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(sh.offsetWidth==target){
clearInterval(sh.timer);
}
else{
sh.style.width=sh.offsetWidth+speed+'px';
}
},30)
}
</script>
</head>
<body>
<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</body>
</html>