Skip to content

Instantly share code, notes, and snippets.

@jeremyckahn
Created April 19, 2011 15:27
Show Gist options
  • Select an option

  • Save jeremyckahn/928430 to your computer and use it in GitHub Desktop.

Select an option

Save jeremyckahn/928430 to your computer and use it in GitHub Desktop.
Useful shim for getting the outerHTML text of a DOM node
// Useful shim for getting the outerHTML text of a DOM node. Requires jQuery.
function getOuterHTML (el) {
var ret, wrapper;
if (el.hasOwnProperty && el.hasOwnProperty('outerHTML')) {
ret = el.outerHTML;
} else {
wrapper = $('<div>').html(el);
ret = wrapper.html();
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment