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

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

加入鏈式動畫的代碼后會出現一個問題?:多1.js:21 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

錯誤提示加了注釋的2行有問題!

只能有第一個動畫,第二個無法進行。錯誤一直累計。百度沒找到解決方法,求教!

op.onmouseover=function(){yd(this,"height",300,function(){yd(this,"width",400);});}

op.onmouseout=function(){yd(this,"height",150,function(){yd(this,"width",200);});}



function getStyle(obj,attr)

{

if(obj.currentStyle){return obj.currentStyle[attr];}

//else { return getComputedStyle(obj,false)[attr];}

}

//iccr=parseInt(getStyle(obj,attr));

正在回答

2 回答

我猜是this的的作用域問題,onmouseover內的function函數應該把this傳參,因為第二個function中的this不再指向op本身。相關的this 問題我也不太明白,正學習

應改為

op.onmouseover = function() {

var that = this //將this傳參

yd(that, "height", 300, function() {

yd(that,"width",400); });

}

不知道對不對,共勉。

3 回復 有任何疑惑可以回復我~

謝謝你,我想起來了,

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

舉報

0/150
提交
取消

加入鏈式動畫的代碼后會出現一個問題?:多1.js:21 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

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

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

幫助反饋 APP下載

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

公眾號

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