未找到相应的内容时,输出没有找到的提示信息
我想如果没有找到值为”javascript“的节点时,输出内容”没有找到相关内容“
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</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");
var childs = content.childNodes;
// 在此完成该函数
for(var i =0;i<childs.length;i++){
var value1=childs[i].innerHTML;
if(value1=="javascript"){
content.removeChild(childs[i]);
}
}
}
</script>
<button onclick="clearText()">清除节点内容</button>
</body>
</html>