X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=7128d11cfb46a82d1b78999a0d6d1476332ad695;hb=2a6de9ab66653e5e424d9cc79d195b555158d04f;hp=baf99d52d90626792b8c966b6dda28e45dd6e097;hpb=aae0617c834a030902cd8da2714f852d6a1431be;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index baf99d5..7128d11 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -210,7 +210,17 @@ jQuery.fn.extend({ replaceWith: function( value ) { if ( this[0] && this[0].parentNode ) { - return this.after( value ).remove(); + return this.each(function(){ + var next = this.nextSibling, parent = this.parentNode; + + jQuery(this).remove(); + + if ( next ) { + jQuery(next).before( value ); + } else { + jQuery(parent).append( value ); + } + }); } else { return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); }