控制台不报错,程序结果不显示运动,这是怎么了?
<!DOCTYPE html>
<html>
<head>
<title>solve bug</title>
<style type="text/css">
ul,li{list-style: none;}
li{
width: 400px;
height: 200px;
background: green;
border: 4px solid #999;
border-radius: 10px;
float: left;
margin:50px;
filter: alpha(opacity:90);
opacity: 0.9;
}
</style>
<script type="text/javascript">
var timer=null;
window.onload=function(){
var li1=document.getElementById('li1');
var li2=document.getElementById('li2');
li1.onmouseover=function(){
startMove(this,'height',400);
}
li1.onmouseout=function(){
startMove(this,'height',200);
}
li2.onmouseover=function(){
startMove(this,'width',600);
}
li2.onmouseout=function(){
startMove(this,'width',400);
}
}
function startMove(obj,attr,yes){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var icce=parseInt(getStyle(obj,attr));
var speed=(yes-obj.icce)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(icce==yes){
clearInterval(obj.timer);
}else{
obj.style[attr]=icce+speed+'px';
}
},30)
}
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
</script>
</head>
<body>
<ul>
<li id="li1"></li>
<li id="li2"></li>
</ul>
</body>
</html>