Skip to content

Instantly share code, notes, and snippets.

@6174
Created August 7, 2013 08:03
Show Gist options
  • Save 6174/6172142 to your computer and use it in GitHub Desktop.
Save 6174/6172142 to your computer and use it in GitHub Desktop.
判断元素节点是否还在dom中
//from api
document.contains(someReferenceToADomElement);
//from job
var elementInDocument = function(element) {
while (element = element.parentNode) {
if (element == document) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment