为什么没有反应 求指教 万分感谢!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
li {
width: 200px;
height: 100px;
background: yellow;
margin-bottom: 20px;
border: 1px solid #807A62;
}
</style>
<script type="text/javascript">
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, 400);
}
aLi[i].onmouseout = function() {
startMove(this, 200);
}
}
}
function startMove(obj, iTarget) {
clearInterval(obj.timer);
obj.timer = setInterval(function() {
var speed=(iTarget-parseInt(getStyle(obj,'width')))/10;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if (parseInt(getStyle(obj,'width'))== iTarget) {
clearInterval(obj.timer);
} else {
obj.style.width = parseInt(getStyle(obj,'width'))+ speed + 'px';
}
}, 30)
}
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return obj.getComputedStyle(obj,false)[attr];
}
}
</script>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>