//这个是js运动框架,后面是调用这个函数 function getStyle(obj,curr) { if(obj.currentStyle) { return obj.currentStyle[curr] } else { return getComputedStyle(obj,false)[curr]; } } function sartMove(obj,attr,iTarget,fnEnd) { clearInterval(obj.timer) var aDiv=document.getElementById('div1') var aDi=document.getElementById('div2') obj.timer=setInterval(function(){ var curr=0 if(attr=='opacity') { curr=Math.round(parseFloat(getStyle(obj,attr))*100); } else { curr=parseInt(getStyle(obj,attr)) } var speed=(iTarget-curr)/6; speed>0?Math.ceil(speed):Math.floor(speed); if(curr==iTarget) { clearInterval(obj.timer) if(fnEnd)fuEnd(); } else { if(attr=='opacity') { obj.style.opacity=(curr+speed)/100; obj.style.fifter='alpha(opacity:'+(curr+speed)+')' } else { obj.style[attr]=curr+speed+'px' } } },30) } //这个是真正的代码,第一个width可以执行,但是第二个alert就执行不了了,求高人帮忙看看
添加回答
举报
0/150
提交
取消