Skip to content

Instantly share code, notes, and snippets.

@mthchz
Created May 22, 2018 17:20
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 mthchz/2680f0568ba2d2ce4822b9a8dccd97aa to your computer and use it in GitHub Desktop.
Save mthchz/2680f0568ba2d2ce4822b9a8dccd97aa to your computer and use it in GitHub Desktop.
Get outer HTML jQuery/JS
/* OuterHtml
*******************************************************************************/
if( !$.outerHTML ){
$.extend({
outerHTML: function(ele) {
if( ele.length === 1 ) return ele[0].outerHTML;
var $return = [];
ele.each(function(i) {
$return.push($(this)[0].outerHTML);
});
return $return;
}
});
$.fn.extend({
outerHTML: function() {
return $.outerHTML($(this));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment