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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

無法在“Node”上執(zhí)行“appendChild”:參數(shù) 1 不是“Node”類型

無法在“Node”上執(zhí)行“appendChild”:參數(shù) 1 不是“Node”類型

瀟瀟雨雨 2023-10-24 21:19:20
我試圖以最簡(jiǎn)單的方式向現(xiàn)有文本添加新文本,在我的情況下,我只能修改段落元素內(nèi)的腳本,但我收到此錯(cuò)誤Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node。我怎樣才能用最短的代碼使其工作?<!-- Many elements above this --><p>  This a part of the text  <script>    document.currentScript.parentNode.appendChild(" and this is the new text added");  </script></p><!-- Many elements under this -->
查看完整描述

1 回答

?
泛舟湖上清波郎朗

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊

textNode您應(yīng)該使用createTextNode()方法創(chuàng)建文本,例如,

const?textNode?=?document.createTextNode("?and?this?is?the?new?text?added");

并將創(chuàng)建的節(jié)點(diǎn)作為參數(shù)傳遞給appendChild,例如

document.currentScript.parentNode.appendChild(textNode);

修改后的片段如下:

<!-- Many elements above this -->

<p>

? This a part of the text

? <script>

? ? const textNode = document.createTextNode(" and this is the new text added");

? ? document.currentScript.parentNode.appendChild(textNode);

? </script>

</p>

<!-- Many elements under this -->


查看完整回答
反對(duì) 回復(fù) 2023-10-24
  • 1 回答
  • 0 關(guān)注
  • 193 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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