Skip to content

Instantly share code, notes, and snippets.

@kpozin
Created January 14, 2011 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpozin/779133 to your computer and use it in GitHub Desktop.
Save kpozin/779133 to your computer and use it in GitHub Desktop.
jQuery.fn.inDom()
/**
* Returns true if this selection is part of the current DOM;
* false if it's a fragment.
* @return {Boolean}
*/
jQuery.fn.inDom() = function() {
// Get the first element in the jQuery selection
var node = this[0];
while (node) {
// See https://developer.mozilla.org/en/nodeType
if (node.nodeType === Node.DOCUMENT_NODE) {
return true;
}
node = node.parentNode;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment