CSS & HTML

jquery 에서의 outerHTML

ImRedCat 2010. 5. 28. 17:49
/*
* jQuery outerHTML
*
* Copyright (c) 2008 Ca-Phun Ung 
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://yelotofu.com/labs/jquery/snippets/outerhtml/
*
* outerHTML is based on the outerHTML work done by Brandon Aaron
* But adds the ability to replace an element.
*/
(function($) {
	$.fn.outerHTML = function(s) {
		return (s) 
			? this.before(s).remove() 
			: $('

').append(this.eq(0).clone()).html(); } })(jQuery);