課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
?tr.setAttribute("onmouseover",dis1(tr));
?tr.setAttribute("onmouseout",dis2(tr));
在添加按鈕時,在新建的元素節(jié)點tr中添加這兩個屬性,咋沒有啥效果的
2016-05-04
源自:JavaScript進(jìn)階篇 9-22
正在回答
tr.setAttribute("onmouseover","dis1()"); tr.setAttribute("onmouseout","dis2()");
??function?dis1(){ ????debugger; ????console.log(event.target); ????this.style.backgroundColor="#f2f2f2"; ??} ??function?dis2(){ ????debugger; ????this.style.backgroundColor="#fff"; ??} ?? ??自己試下,看看this是什么,看看console.log(event.target)打印出什么。
我也覺得,要不加“”試下
然后,方法要不要也要用“”括起來,試試吧
方法里面是不是應(yīng)該寫的是this?
舉報
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動態(tài)交互世界
5 回答setAttribute
2 回答setAttribute方法
2 回答setAttribute問題
1 回答setAttribute()問題
2 回答SetAttribute()問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-05-10
2016-05-04
我也覺得,要不加“”試下
2016-05-04
然后,方法要不要也要用“”括起來,試試吧
2016-05-04
方法里面是不是應(yīng)該寫的是this?