Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gets outerHTML of an element
/**
* Gets outerHTML of an element
*/
;(function (global) {
var $ = global.jQuery || global.Zepto;
$.fn.outerHTML = function fouterHTML() {
$t = $(this);
if ('outerHTML' in $t[0]) {
return $t[0].outerHTML;
}
else {
var content = $t.wrap('<div></div>').parent().html();
$t.unwrap();
return content;
}
} ;
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment