<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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=document.getElementsByTagName("li").[1];
var newnode=document.createElement("li");
newnode.innerHTML="PHP";
otest.insertBefore(newnode,node);
</script>
</body>
</html>
var otest = document.getElementById("test");
var sp=document.createElement('li');
sp.innerHTML='php';
otest.insertBefore(sp,otest.childNodes[1]);
var otest = document.getElementById("test");
var new_li = document.createElement("li");
new_li.innerHTML = "php";
otest.insertBefore(new_li,otest.lastChild);
var node=document.getElementsByTagName("li").[1]中[1]前面不应该有一点.,去掉就运行出来了
哪里?
a 。。。。。发现问题了....