Let\'s say that I define an element
$foo = $(\'#foo\');
and then I call
$foo.remove()
from some event. My
Like this:
if (!jQuery.contains(document, $foo[0])) { //Element is detached }
This will still work if one of the element's parents was removed (in which case the element itself will still have a parent).