为什么 只有一个属性好使
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/master.css">
</head>
<body>
<script>
window.onload=function(){
var ali = document.getElementsByTagName("li");
for(var i= 0;i<ali.length;i++){
ali[i].timer=null
ali[i].onmouseover=function(){
startMove(this,'height',400);
}
ali[i].onmouseout=function(){
startMove(this,'height',100);
}
ali[i].onmouseover=function(){
startMove(this,'width',400);
}
ali[i].onmouseout=function(){
startMove(this,'width',200);
}
}
}
// var timer = null
function startMove(obj,attr,iTarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var icor = parseInt(getStyle(obj,attr));
var speed =(iTarget-icor)/8
speed=speed>0?Math.ceil(speed):Math.floor(speed)
if(icor==iTarget){
clearInterval(obj.timer);
}else{
obj.style[attr]=icor+speed+"px";
// obj.style.fontSize=parseInt(getStyle(obj,"fontSize"))+speed+"px";
}
},30)
}
function getStyle(obj,attr){
if(obj.currentsyle){
return obj.currentsyle[attr]; //针对ie浏览器
}else{
return getComputedStyle(obj,false)[attr]; //针对firefox浏览器
}
}
</script>
<script>
</script>
<ul>
<li>1111111</li>
<!--
<li>11111</li>
<li>11111</li>
-->
</ul>
</body>
</html>