哪里错了,求指教(insertBefore相关内容)
<!DOCTYPE HTML>
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<ul id="test"><li>JavaScript</li><li>HTML</li></ul>
<script type="text/javascript">
var otest = document.getElementById("test");
var node;//内容为HTML的标签
var newNode = document.createElement("li");
newNode.innerHTML = "PHP";
var i = 0;
while(otest.childNodes[i]){
if(otest.childNodes[i].innerHTML == "HTML"){
node = otest.chhildNodes[i];
break;
}
i++;
}
otest.insertBefore(newNode,node);
</script>
</body>
</html>