Skip to content

Instantly share code, notes, and snippets.

@jvandyke
Created October 4, 2011 16:42
Show Gist options
  • Save jvandyke/1262132 to your computer and use it in GitHub Desktop.
Save jvandyke/1262132 to your computer and use it in GitHub Desktop.
Function to determine if the given thing is an element.
/**
* Returns true if the given object is an element.
* @param thing {object/jQuery}
* @returns {boolean}
*/
function isDomElement(thing)
// If you would like this function to handle jQuery objects.
if (thing && thing.jquery) {
thing = thing.get(0);
}
return (typeof thing === "object" && typeof thing.nodeName !== "undefined");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment