代码如下,但IE没有动画效果,有大神可以解释下吗?
window.onload=drag;
function drag(){
var div1=document.getElementById('div1');
div1.onmouseover=function(){changeOpacity(100);}
div1.onmouseout=function(){changeOpacity(20);}
}
var timer=null;
var alpha=20;
function changeOpacity(num){
var div1=document.getElementById('div1');
clearInterval(timer);
timer=setInterval(function(){
var speed=0;
if(num>alpha){speed=10;} else{speed=-10;}
if(alpha==num){clearInterval(timer);}else{
alpha+=speed;
div1.style.filter='alpha(opacity:'+alpha+')';
div1.style.opacity=alpha/100;}
},50);
}