Created
April 19, 2011 15:27
-
-
Save jeremyckahn/928430 to your computer and use it in GitHub Desktop.
Useful shim for getting the outerHTML text of a DOM node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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