4 "./traversing" // parent, contents
5 ], function( jQuery ) {
8 wrapAll: function( html ) {
9 if ( jQuery.isFunction( html ) ) {
10 return this.each(function(i) {
11 jQuery(this).wrapAll( html.call(this, i) );
16 // The elements to wrap the target around
17 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
19 if ( this[0].parentNode ) {
20 wrap.insertBefore( this[0] );
26 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
27 elem = elem.firstChild;
37 wrapInner: function( html ) {
38 if ( jQuery.isFunction( html ) ) {
39 return this.each(function(i) {
40 jQuery(this).wrapInner( html.call(this, i) );
44 return this.each(function() {
45 var self = jQuery( this ),
46 contents = self.contents();
48 if ( contents.length ) {
49 contents.wrapAll( html );
57 wrap: function( html ) {
58 var isFunction = jQuery.isFunction( html );
60 return this.each(function(i) {
61 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
66 return this.parent().each(function() {
67 if ( !jQuery.nodeName( this, "body" ) ) {
68 jQuery( this ).replaceWith( this.childNodes );