How do I check whether a jQuery element is in the DOM?
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).
How about doing this:
$element.parents('html').length > 0