var t = document.createElement('DIV'); document.body.appendChild(t); alert(t in document.body)
function inDocument( node ) { var context = node.parentNode; while ( context !== null ) { if ( context === document )return true; else context = context.parentNode; } return false; }