Javascript: how to tell if a node object has been inserted into a document yet
        Posted  
        
            by thomasrutter
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by thomasrutter
        
        
        
        Published on 2010-04-12T05:56:18Z
        Indexed on 
            2010/04/12
            6:03 UTC
        
        
        Read the original article
        Hit count: 364
        
I'd like to be able to identify whether a given DOM node has been inserted into a document, or part of one, yet, or whether it is fresh out of document.createElement() or similar and has not been placed anywhere.
In most browsers just checking the parentNode works.
if (!node.parentNode) {
  // this node is not part of a larger document
}
However, in Internet Explorer it appears that new elements, even right after they've been created with document.createElement() already have a parentNode object (of type DispHTMLDocument??).
Any other nice cross-browser and reliable way?
© Stack Overflow or respective owner