第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

對(duì)象的屬性設(shè)置問(wèn)題

tr是創(chuàng)建的行的對(duì)象

1.按照下面代碼,

tr.lastChild.firstChild.onclick="deleteNode(this);";

tr.onmouseover="this.style.background='yellow'";

tr.onmouseout="this.style.background='#fff'";

console.log("打印tr.lastChild.firstChild.onclick內(nèi)容:"+tr.lastChild.firstChild.onclick);

console.log("打印tr.onmouseover內(nèi)容:"+tr.onmouseover);

console.log("打印tr.onmouseout內(nèi)容:"+tr.onmouseout);

通過(guò)console.log輸出的都為null,不能正常執(zhí)行,為什么???


2.按照下面代碼

tr.lastChild.firstChild.onclick=function(){

deleteNode(this);

}

tr.onmouseover=function(){

this.style.background="yellow";?

}

tr.onmouseout=function(){

this.style.background="#fff";?

}

通過(guò)console.log輸出的都正常,能夠正常執(zhí)行。


3.通過(guò)下列代碼

tr.lastChild.firstChild.setAttribute("onclick","deleteNode(this);");

tr.setAttribute("onmouseover","this.style.background='yellow'");

tr.setAttribute("onmouseout","this.style.background='#fff'");

通過(guò)console.log輸出的都正常,能夠正常執(zhí)行。

正在回答

1 回答

第一個(gè)里面目測(cè)是無(wú)法將字符串類型的對(duì)象隱式轉(zhuǎn)換為事件的類型。或者說(shuō)程序并不知道你給OnClick事件賦值的結(jié)果是什么。

第二個(gè),很明顯的通過(guò)調(diào)用函數(shù)來(lái)執(zhí)行你需要執(zhí)行的刪除操作,沒有問(wèn)題。

第三個(gè),通過(guò)設(shè)置節(jié)點(diǎn)的屬性,類似與你在創(chuàng)建節(jié)點(diǎn)的時(shí)候,就已經(jīng)在里面寫入onclick="deleteNode(this)"。

是我的一些看法,希望對(duì)你有所幫助。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JavaScript進(jìn)階篇
  • 參與學(xué)習(xí)       468770    人
  • 解答問(wèn)題       22442    個(gè)

本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁(yè)動(dòng)態(tài)交互世界

進(jìn)入課程

對(duì)象的屬性設(shè)置問(wèn)題

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)