點(diǎn)了沒反應(yīng)。。
誰(shuí)幫我看一下為什么點(diǎn)了按鈕沒反應(yīng)。。
<!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");
? /*方法一:for(var i=content.childNodes.length-1;i>=0;i--){
????? var yy=content.removeChild(content.childNodes[i]);
? }
? document.write(yy.innerHTML+"<br/>");*/
? /*方法二:var length = content.childNodes.length;
? while(length--){
???? var x = content.removeChild(content.childNodes[0]);
???? document.write("刪除節(jié)點(diǎn)的內(nèi)容"+x.innerHTML+"<br/>");
? }下面是方法三:*/
? /while(content.firstChild!==null){
??? var re=content.removeChild(content.firstChild);
??? re=null;
? }
</script>
<button onclick="clearText()">清除節(jié)點(diǎn)內(nèi)容</button>
</body>
</html>
2016-06-06
打開方式不對(duì),換個(gè)瀏覽器試試