为什么结果不是将PHP插入到HTML之前?(insertBefore相关)
<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].nodeValue == "HTML"){ node = otest.chhildNodes[i]; break; } i++; } otest.insertBefore(newNode,node); </script> </body>