比较appendChild和insertBefore的区别

<html>
<script>
function fnAppend(){
var oNewNode = document.createElement("DIV");
oList.appendChild(oNewNode);
oNewNode.innerText="List node 5";
}

function Insert(){
var oNewNode = document.createElement("DIV");
oList.parentNode.insertBefore(oNewNode,oList);
oNewNode.innerText="List node 6";
}
</script>
<body>
我在做测试啦!
<br>
比较appendChild和insertBefore的区别
<div id = oList>
<div>List node 1</div>
<div>List node 2</div>
<div>List node 3</div>
<div>List node 4</div>
</div>
<input type = "button" value = "Append Child" onclick = "fnAppend()" /><br />
<input type = "button" value = "InsertBefore" onclick = "Insert()" />
</body>
</HTML>
原文地址:https://www.cnblogs.com/zwei1121/p/688516.html