Skip to content

Instantly share code, notes, and snippets.

@kflorence
Created April 28, 2011 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kflorence/947080 to your computer and use it in GitHub Desktop.
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
(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 );
@kflorence
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment