求助:实在是不知道哪里错了,怎么调透明度都不变
<!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>
*{margin:0;padding:0;}
ul,li{list-style: none;
}
ul li{
width:200px;
height:200px;
background:#666;
margin: 10px;
float: left;
opacity: 0.3;
}
</style>
<script type="text/javascript">
window.onload=function(){
var oLi=document.getElementsByTagName("li");
for (var i = 0;i<oLi.length;i++){
oLi[i].alpha=30;
oLi[i].onmouseover=function(){
startMove(this,100);
}
oLi[i].onmouseout=function(){
startMove(this,30);
}
}
}
function startMove(obj,iwidth){
//var oLi=document.getElementsByTagName("li");
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=0;
if (obj.alpha>iwidth) {
speed=-10;
}else{
speed=10;
};
if (obj.alpha==iwidth) {
clearInterval(obj.timer);
}else{
obj.alpha=obj.alpha+speed+"px";
obj.style.opacity=obj.alpha/100;
}
},30)
}
</script>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>