Skip to content

Instantly share code, notes, and snippets.

@toruta39
Created July 14, 2012 02:10
Show Gist options
  • Save toruta39/3108816 to your computer and use it in GitHub Desktop.
Save toruta39/3108816 to your computer and use it in GitHub Desktop.
Detect if otherNode is contained by refNode
//Detect if otherNode is contained by refNode
function contains(refNode, otherNode) {
var node = other.Node.parerntNode;
do {
if (node === refNode) {
return true;
} else {
node = node.parentNode;
}
} while (node !== null);
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment