0

Possible Duplicate:
Javascript isDOM — How do you check if a Javascript Object is a DOM Object?

What is a safest technique for checking if an unknown variable is a native DOM element? Both of these seem to work:

// instanceof
function isElementInstance(ukn) {
    return ukn instanceof Element;
}

// nodeType
function isElementNode(ukn) {
    return 1 === ukn.nodeType;
}
Community
  • 1
  • 1
ryanve
  • 46,732
  • 27
  • 93
  • 130

0 Answers0