<div>
<h1 id = "first">first</h1>
<h1 id="second">second</h1>
<input type="button" onclick="test()" value="insertBefore" />
</div>
<script>
function test(){
var headObj = document.getElementById("first");
var obj= document.createElement("h1");
var newValue = document.createTextNode("xin cha ru hang");
obj.appendChild(newValue);
headObj.parentNode.insertBefore(obj,headObj);
}
</script>
node.parentNode.insertBefore(新添加节点,参照节点)_注意:node.parentNode是节点的父节点