东儿童
爱拼才会赢
这里是从 NodeA.compareDocumentPosition(NodeB) 返回的结果,包含你可以得到的信息。 

Bits          Number        Meaning 
000000         0              元素一致 
000001         1              节点在不同的文档(或者一个在文档之外) 
000010         2              节点 B 在节点 A 之前 
000100         4              节点 A 在节点 B 之前 
001000         8              节点 B 包含节点 A 
010000         16             节点 A 包含节点 B 
100000         32             浏览器的私有使用 

现在,这意味着一个可能的结果类似于: 



<div id="a"> 
<div id="b"></div> 
</div> 
<script> 
alert( document.getElementById("a").compareDocumentPosition(document.getElementById("b")) == 20); 
</script> 


一旦一个节点 A 包含另一个节点 B,包含 B(+16) 且在 B 之前(+4),则最后的结果是数字 20 。  
posted on 2012-06-12 16:52  哎!无悔  阅读(525)  评论(0编辑  收藏  举报