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

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

為啥我這樣寫網(wǎng)頁炸了而且還刷新不了

https://img1.sycdn.imooc.com//5d6126fc000161b508670476.jpg為啥我這樣寫網(wǎng)頁炸了而且還刷新不了

正在回答

2 回答

問題解決了,望采納

<!DOCTYPE HTML>


<html>


<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


<title>無標(biāo)題文檔</title>


</head>



<body>


<div id="content">

<h1>html</h1>

<h1>php</h1>

<h1>javascript</h1>

<h1>jquery</h1>

<h1>java</h1>


</div>



<script type="text/javascript">


function clearText()

{

var content=document.getElementById("content");



document.write("content.innerHTML:<br>"+content.innerHTML);

document.write("content.childNodes[0].nodeValue="+content.childNodes[0].nodeValue+"<br>");

document.write("content.childNodes[1].nodeValue="+content.childNodes[1].nodeValue+"<br>");

document.write("content.childNodes[2].nodeValue="+content.childNodes[2].nodeValue+"<br>");

document.write("content.childNodes[0].nodeType="+content.childNodes[0].nodeType+"<br>");

document.write("content.childNodes[1].nodeType="+content.childNodes[1].nodeType+"<br>");

document.write("content.childNodes[2].nodeType="+content.childNodes[2].nodeType+"<br>");

document.write("content.childNodes[0].nodeName="+content.childNodes[0].nodeName+"<br>");

document.write("content.childNodes[1].nodeName="+content.childNodes[1].nodeName+"<br>");

document.write("content.childNodes[2].nodeName="+content.childNodes[2].nodeName+"<br><br><br>");

var otest = document.getElementsByTagName("h1");

document.write("content.childNodes.length="+content.childNodes.length+"<br>");

document.write("otest.length="+otest.length+"<br>");


var a = content.childNodes.length-1;

for(var i=a;i>=0;--i)

?

{

document.write("i="+i +"<br>");

document.write("content.childNodes[i].nodeName="+content.childNodes[i].nodeName +"<br>");

document.write("content.childNodes[i].nodeType="+content.childNodes[i].nodeType +"<br>");

while(content.childNodes[i].nodeType!="1")


{


--i;

}

document.write("content.childNodes[i].nodeName="+content.childNodes[i].nodeName +"<br>");

document.write("content.childNodes[i].nodeType="+content.childNodes[i].nodeType +"<br>");

? content.removeChild(content.childNodes[i]);


document.write(content.innerHTML);

? ? }

}

</script>



<button onclick="clearText()">清除節(jié)點內(nèi)容</button>

</body>

</html>


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


function clearText() {

? var content = document.getElementById("content");

// 1. 刪除該節(jié)點的內(nèi)容,先要獲取子節(jié)點。

var child = content.childNodes;

// 2. 然后使用循環(huán)遍歷每個子節(jié)點。

for (var i = child.length - 1; i >= 0; i--) {

// 3. 使用removeChild()刪除節(jié)點。

content.removeChild(child[i]);

}

}


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

舉報

0/150
提交
取消
JavaScript進階篇
  • 參與學(xué)習(xí)       468777    人
  • 解答問題       22474    個

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

進入課程

為啥我這樣寫網(wǎng)頁炸了而且還刷新不了

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

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

幫助反饋 APP下載

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

公眾號

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