1. contains()
주어진 노드가 다른 노드의 자손인지 확인
http://help.dottoro.com/ljgjmtaa.php
브라우져 공용 함수
function contains(refNode, otherNode)
{
if(refNode.contains)
{
return refNode.contains(otherNode);
}
else if(refNode.compareDocumentPosition)
{
return !!(refNode.compareDocumentPosition(otherNode) & 16);
}
else
{
var node = otherNode.parentNode;
while(node != null)
{
if(node == refNode)
return true;
node = nope.parentNode;
}
return false;
}
}
2. comapreDocumentPosition()
좀더 복잡한 노드 사이의 관계 확인
단절/선행/후행/조상/자손
http://help.dottoro.com/ljgoeost.php
'웹' 카테고리의 다른 글
중앙 집중형 타이머 관리 (0) | 2018.09.18 |
---|---|
함수 감속 (0) | 2018.08.07 |
javascript DOM tree 를 node 기준으로 split 하기 (0) | 2018.05.04 |
javascript 요소 크기 (element offset / client / scroll ) (0) | 2018.05.01 |