Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Created September 29, 2011 11: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 barneycarroll/1250576 to your computer and use it in GitHub Desktop.
Save barneycarroll/1250576 to your computer and use it in GitHub Desktop.
$.outerHTML()
// Cross-browser outerHTML: return it, or if an argument was passed, replace the element.
$.fn.outerHTML = function(arg){
var $el = this;
return arg
? $el.replaceWith(arg)
: $el.clone().wrap('<b>').parent().html();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment