當前位置:
首頁 >
判断节点包含
發布時間:2025/3/17
48
豆豆
- 元素包含
contains基本兼容
用法node.contains( otherNode )
compareDocumentPosition感覺比較奇怪,據說是這樣
The Node.compareDocumentPosition() method compares the position of the
current node against another node in any other document.
返回值分為6個數字
jquery的selector-native有個原生方法contains這樣寫的
比較容易理解
update 2015-01-27
開發鳳凰焦點項目的時候,有用到判斷元素包含關系的contains,當時第一反應是想到jquery取子元素的方式.(之前看過實現方式的,忘了2333...)當然不是用的contains,因為相比取子元素更適合關系判斷.那么jq是怎么取的呢?
- node.nextSibling
- node.previousSibling
沒錯,就是這倆屬性,traversing.js腳本可見
轉載于:https://www.cnblogs.com/kite-Runner/p/4222920.html
總結
- 上一篇: ANDROID L——Material
- 下一篇: canvas学习