Created
January 21, 2015 18:52
-
-
Save brenopolanski/750a453368bb0ef380ce to your computer and use it in GitHub Desktop.
A jQuery plugin to retrieve the outerHTML of an element
This file contains 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
/*! Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) | |
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) | |
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. | |
*/ | |
(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