哪里錯(cuò)了,求指教(insertBefore相關(guān)內(nèi)容)
<!DOCTYPE HTML>
<html>
<head>
<title>無標(biāo)題文檔</title>
</head>
<body>
<ul id="test"><li>JavaScript</li><li>HTML</li></ul>
?
<script type="text/javascript">
? var otest = document.getElementById("test"); ?
? var node;//內(nèi)容為HTML的標(biāo)簽
? 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>
2016-09-18
? node = otest.chhildNodes[i];
chhild 多打h 打錯(cuò)字注意檢查不要亂掛
2016-09-28
while(otest.childNodes[i]){
???????? if(otest.childNodes[i].innerHTML == "HTML"){
???????????? node = otest.chhildNodes[i];
???????????? break;
???????? }
???????? i++;
? }?
2016-09-18
?node = otest.chhildNodes[i];