为什么我的没有任何效果呢。。
<!DOCTYPE html>
<html>
<head>
<title>多物体透明度</title>
<style type="text/css">
div{
background-color:yellow;
height:200px;
width:200px;
margin:20px;
float:left;
opacity:0.3;
filter:alpha(opacity:0.3);
}
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<script type="text/javascript">
window.onload=function(){
var oDIV=document.getElementsByTagName('div');
for (var i = 0; i < oDIV.length; i++) {
oDIV[i].alpha=30;
oDIV[i].onmouseover=function(){
onMove(this,100);
}
oDIV[i].onmouseover=function(){
onMove(this,30);
}
}
}
function onMove(obj,iTarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=0;
speed=(iTarget-obj.alpha)/10;
if (obj.alpha==iTarget) {
clearInterval(obj.timer);
}
else{
obj.alpha+=obj.speed;
obj.style.opacity=obj.alpha/100;
obj.style.filter="alpha(opacity:"+obj.alpha+")";
}
},30)
}
</script>
</body>
</html>