这段代码为什么实现不了
window.onload=ChangeColor;
function ChangeColor() {
var box=document.getElementsByTagName("div");
for (var i = 0; i < box.length; i++) {
box[i].timer=null;
box[i].alpha=30;
box[i].onmouseover=function(){
ChageAlpha(this,100);
}
box[i].onmouseout=function(){
ChageAlpha(this,30);
}
}
}
function ChageAlpha(obj,iTarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=0;
if (obj.alpha>iTarget) {
speed=5;
}else{
speed=-5;
}
if (obj.alpha==iTarget) {
clearInterval(obj.timer);
}else{
obj.alpha+=speed;
obj.style.filter='alpha(opacity:'+obj.alpha+')';
obj.style.opacity=obj.alpha/100;
}
},30)
}