<html>
<head>
</head>
<body>
<div id="content">
<div>
<div id="bingo">Bingo</div>
</div>
</div>
<script type="text/javascript">
// В FF нет contains, нужно сделать
if (window.Node && Node.prototype && !Node.prototype.contains)
{
Node.prototype.contains = function (arg) {
return !!(this.compareDocumentPosition(arg) & 16)
}
}
var bingo = document.getElementById('bingo');
var content = document.getElementById('content');
alert(document.contains(bingo));
content.innerHTML = '<div><div id="bingo">Bingo 2</div></div>';
alert(document.contains(bingo));
</script>
</body>
</html>
http://www.quirksmode.org/dom/w3c_core.html#t111