听的云里雾里,出问题了,麻烦帮我看看
function onmove(obj,json,fn){
clearInterval(obj.timer);
var oar=0;
obj.timer=setInterval(function(){
var flag=true; //假设
for(var attr in json){
if(attr=="opacity"){
oar=getStyle(obj,attr)*100;
}else{
oar=parseInt(getStyle(obj,attr));
}
var speed=oar<json[attr]?10:-10;
if(oar!=json[attr]){
flag=false; //假设全部都没有实现完成
}
if(attr=="opacity"){
obj.style[attr]=(oar+speed)/100;
obj.style.filter='Alpha(opacity:'+oar+speed+')';
}
else{
obj.style[attr]=oar+speed+'px';
}//要把这里的style.attr改成style[attr]
}
if(flag==true){ //全部都实现了
clearInterval(obj.timer);
if(fn){
fn();
}
}
},30);
}
//方法封装--获取属性
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];//IE浏览器
}else{
return getComputedStyle(obj,false)[attr];//火狐浏览器
}
}