我这个代码哪里出错了,为什么鼠标移上去没用的?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body{
margin: 0px;
}
li{
width: 200px;
height: 50px;
list-style-type: none;
margin-bottom: 10px;
background-color: brown;
}
</style>
<script type="text/javascript">
window.onload = function(){
var myli = document.getElementsByTagName('li');
for(var i=0;i<myli.length;i++){
myli[i].timer=null;
myli[i].onmouseover = function(){
startMove(this,500);
}
myli[i].onmouseout = function(){
startMove(this,200);
}
}
}
function startMove(obj,myattr){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var speed = (myattr-obj.offsetWidth)/10;
speed = speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.offsetWidth==myattr){
clearInterval(obj.timer);
}else
{
obj.offsetWidth=obj.offsetWidth+speed+'px';
}
},30)
}
</script>
</head>
<body>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</body>
</html>