亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么CHROME報錯說Uncaught TypeError: Cannot read property 'currentStyle' of undefined

function getStyle(obj,attr) {

if (obj.currentStyle) {

return obj.currentStyle[attr];

}

else{

return getComputedStyle(obj,false)[attr];

? ? }

}


function startMove(obj,json,fn) {

var flag = true ;?

clearInterval(obj.timer);

obj.timer=setInterval(function () {

for(var attr in json) {

//取當前值

var icur = 0;

if(attr=='opacity') {

icur=Math.round(parseFloat(getStyle(obj,attr))*100);

}

else{

icur=parseInt(getStyle(obj.attr));

}

//計算速度

var ispeed=(json[attr]-icur)/8;

ispeed=ispeed>0?Math.ceil(ispeed):Math.floor(ispeed);

//檢測停止

if(icur!=json[attr]) {

flag=false;

}

if(attr=='opacity') {

? ? ? ? ? ? ? ? obj.style.filter='alpha(opacity:'+(icur+ispeed)+')';

? ? ? ? ? ? ? ? obj.style.opacity=(icur+ispeed)/100;

}

? ? ? ? ? ? else{

? ? ? ? ? ? obj.style[attr]=icur+ispeed+'px';

? ? ? ? ? ? } ? ?

}

if(flag){

? ? ? ? ? ? clearInterval(obj.timer);

? ? ? ? ? ? if(fn){

? ? ? ? ? ? fn();

? ? ? ? ? ? }

? ? ? ? ? ? }

},30);

}


正在回答

1 回答

不知道,我有沒有看錯;

obj.attr 而不是obj, attr;?

逗號;

一個傳參數,一個查屬性


0 回復 有任何疑惑可以回復我~
#1

Redchan 提問者

非常感謝!
2016-04-20 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么CHROME報錯說Uncaught TypeError: Cannot read property 'currentStyle' of undefined

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號