1. 程式人生 > 其它 >javascript當中insertBefore的用法

javascript當中insertBefore的用法

javascript當中insertBefore的用法

例 1.3(insertBeforeIEFF.html)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</HEAD>
<BODY>
<div id="contain">
<p id="content">1111</p>
<div id="msg">
msg
<div>test</div>
</div>
<p id="content1">222</p>
<p id="aaa">aaaaaaaa</p>
</div>
end
<div id="insertedNode">insertedNode</div>
<script>
var insertedNode = document.getElementById("insertedNode");
var aaa = document.getElementById("aaa");
var test = document.getElementById("contain");
/*
馬克-to-win: first comment out the following statement, see the effect, then uncomment out the following statement, see the effect again.

Node.insertBefore() (Method)
This method inserts a child element into the collection at the indicated position.(qixy: here
"contain" is a collecton.)

返回值:Property/method value type: Node object
JavaScript syntax: - myNode.insertBefore(aNode1, aNode2)
Argument list: aNode1 The node to be inserted
aNode2 The node indicating the insertion point


更多內容請見原文,文章轉載自:

https://blog.csdn.net/qq_44594371/article/details/103063631