課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
為什么我的結(jié)果是這樣[object HTMLParagraphElement] [object HTMLHeadingElement]
2018-06-03
源自:JavaScript進(jìn)階篇 9-9
正在回答
你的代碼是什么?
因?yàn)槟銢]有加節(jié)點(diǎn)屬性,直接輸出了,我猜你的代碼是——
document.write(x.firstChild); document.write(x.lastChild);
加上節(jié)點(diǎn)屬性就能輸出你想獲取的節(jié)點(diǎn)名稱、值和類型了,如——
document.write(x.firstChild.nodeName); document.write(x.firstChild.nodeValue); document.write(x.firstChild.nodeType);
我想你應(yīng)該是沒有var x=document.getElementById("con");? document.write(x.firstChild.nodeName+"<br>");? document.write(x.lastChild.nodeName);
舉報(bào)
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動(dòng)態(tài)交互世界
2 回答結(jié)果為什么是[object Text][object Text]
2 回答為什么輸出結(jié)果是這樣的?
1 回答我的天??!為什么輸出是這樣的結(jié)果?。?!
4 回答我的這個(gè)刪除的代碼為什么傳的參數(shù)是[Object Window]呢?
3 回答返回值是[object Text][object Text]對(duì)嗎?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-06-04
你的代碼是什么?
2019-02-28
因?yàn)槟銢]有加節(jié)點(diǎn)屬性,直接輸出了,我猜你的代碼是——
加上節(jié)點(diǎn)屬性就能輸出你想獲取的節(jié)點(diǎn)名稱、值和類型了,如——
2018-07-23
我想你應(yīng)該是沒有var x=document.getElementById("con");
? document.write(x.firstChild.nodeName+"<br>");
? document.write(x.lastChild.nodeName);