Skip to content

Instantly share code, notes, and snippets.

@bgrins
Created August 6, 2010 14:16
Show Gist options
  • Save bgrins/511371 to your computer and use it in GitHub Desktop.
Save bgrins/511371 to your computer and use it in GitHub Desktop.
/*
jQuery outerHTML plugin with ownerDocument fix
See: http://www.briangrinstead.com/blog/jquery-outerhtml-snippet
Based off of: http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/
*/
$.fn.outerHTML = function() {
var doc = this[0] ? this[0].ownerDocument : document;
return $('<div>', doc).append(this.eq(0).clone()).html();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment