Created
June 24, 2010 19:54
-
-
Save cowboy/451887 to your computer and use it in GitHub Desktop.
jQuery outerHTML plugin
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
/*! | |
* jQuery outerHTML - v0.3 - 06/25/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
* | |
* Inspired by Brandon Aaron's outerHTML plugin. | |
* http://github.com/brandonaaron/jquery-outerhtml | |
*/ | |
(function($){ | |
'$:nomunge'; // Used by YUI compressor. | |
var div = $('<div/>'); | |
$.fn.outerHTML = function() { | |
var elem = this[0], | |
tmp; | |
return !elem ? null | |
: typeof ( tmp = elem.outerHTML ) === 'string' ? tmp | |
: 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
My changes have been merged into brandon's plugin, so use that instead of this gist!