javascript contains() method

2018. 5. 1. 18:18

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





Posted by 창의력대장3
,