<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
ul li{ list-style:none;}
li{
height:50px;
width:200px;
background-color:#666;
margin-bottom:10px;}
</style>
<script>
window.onload=function(){
var speed;
var li1=document.getElementById("li1");
var li2=document.getElementById("li2");
var li3=document.getElementById("li3");
li1.onmouseover=function(){move(this,"width",400)}
li1.onmouseout=function(){move(this,"widht",200)}
li2.onmouseover=function(){move(this,"height",400)}
li2.onmouseout=function(){move(this,"height",200)}
li3.onmouseover=function(){move(this,"height",400)}
li3.onmouseout=function(){move(this,"height",200)}
}
function getStyle(obj,attr){
if(obj.currentStyle){return obj.currentStyle[attr]}
else{return getComputedStyle(obj,false)[attr]; }
}
function move(obj,attr,target){
clearInterval(obj.time);
obj.time=setInterval(function()
{
var num=parseInt(getStyle(obj,attr));
speed=(target-num)/10;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(num==target){clearInterval(obj.time)}
else{
obj.style.attr=num+speed+"px";}
},30)
}
</script>
</head>
<body>
<div>
<ul>
<li id="li1"></li>
<li id="li2"></li>
<li id="li3"></li>
</ul>
</div>
</body>
</html>