Created
July 17, 2012 12:29
-
-
Save toruta39/3129162 to your computer and use it in GitHub Desktop.
Another way to use iterative to check if otherNode is a child element of refNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Inspired by jQuery, link: http://www.zhangsuoyong.com/?p=111 | |
function checkParent(refNode, otherNode) { | |
var parent = otherNode.parentNode; | |
try { | |
while ( parent && parent !== refNode ) { | |
parent = parent.parentNode; | |
} | |
return (parent !== refNode); | |
} catch(e) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment