Skip to content

Instantly share code, notes, and snippets.

@gcpantazis
Created June 4, 2012 22:37
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 gcpantazis/2871256 to your computer and use it in GitHub Desktop.
Save gcpantazis/2871256 to your computer and use it in GitHub Desktop.
Add jQuery support for outerHTML, with feature detection
// Add support for outerHTML, which in FF was only added at version 11.
// Only use elem.outerHTML once support for FF<11 is no longer needed.
(function($){
$.fn.outerHTML = function() {
var a = this.get(0).outerHTML;
return a ? a : $('<p/>').append(this.clone()).html();
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment