Skip to content

Instantly share code, notes, and snippets.

@bhavyaw
Created July 21, 2016 10:13
Show Gist options
  • Save bhavyaw/fbe10bd7a6ad8d0d62318afa208744e8 to your computer and use it in GitHub Desktop.
Save bhavyaw/fbe10bd7a6ad8d0d62318afa208744e8 to your computer and use it in GitHub Desktop.
function elementChecker(element,selectorName,selectorValue){
// if this node is not the one we want, move up the dom tree
while (element != null && element[selectorName] != selectorValue) {
element = element.parentNode;
}
// at this point we have found our containing div or we are out of parent nodes
var insideMyDiv = (element != null && element[selectorName] == selectorValue);
return {
clicked : insideMyDiv,
element : element
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment