Skip to content

Instantly share code, notes, and snippets.

@dantheman213
Created December 23, 2015 22:44
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 dantheman213/955e08d8f779eefbdcb9 to your computer and use it in GitHub Desktop.
Save dantheman213/955e08d8f779eefbdcb9 to your computer and use it in GitHub Desktop.
jquery outerhtml
(function($){
var div;
$.fn.outerHTML = function() {
var elem = this[0],
tmp;
return !elem ? null
: typeof ( tmp = elem.outerHTML ) === 'string' ? tmp
: ( div = div || $('<div/>') ).html( this.eq(0).clone() ).html();
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment