Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Created July 19, 2011 11:10
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 marek-saji/1092005 to your computer and use it in GitHub Desktop.
Save marek-saji/1092005 to your computer and use it in GitHub Desktop.
jquery.outerhtml.js
(function ($) {
var nativeOuterHtml = ('outerHTML' in document.createElement('div'));
$.fn.outerHtml = function () {
if (nativeOuterHtml) {
return this[0].outerHTML;
}
else {
return this.eq(0).clone().appendTo($('<div />')).parent().html();
}
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment