Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.
$.fn.outerHTML = function() {
var a = this.get(0).outerHTML;
return a ? a : $('<p/>').append(this.clone()).html();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment