Created
April 28, 2011 19:14
-
-
Save kflorence/947080 to your computer and use it in GitHub Desktop.
Convenience methods to determine whether or not an element is attached or detached from the DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( jQuery ) { | |
jQuery.extend({ | |
attached: function( elem ) { | |
if ( elem instanceof jQuery ) { | |
elem = elem[ 0 ]; | |
} | |
return jQuery.contains( elem.ownerDocument.documentElement, elem ); | |
}, | |
detached: function( elem ) { | |
return !jQuery.attached( elem ); | |
} | |
}); | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: http://jsfiddle.net/kflorence/GwRSW/