Bug Tracker

Opened 13 years ago

Closed 13 years ago

#1296 closed feature (fixed)

new method - innerWrap , does wrap on an elements children

Reported by: wjessup Owned by:
Priority: minor Milestone: 1.2
Component: core Version: 1.1.4
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by brandon)

<div>

<span></span> <span></span>

</div>


$('div').innerWrap("<p></p>");

#=>

<div>

<p>

<span></span> <span></span>

</p>

</div>


jquery.js #=> ln 142

backwards compatibility for wrap

wrap: function(){

return outerWrap();

},

outerWrap: function() {

The elements to wrap the target around var a = jQuery.clean(arguments);

Wrap each of the matched elements individually return this.each(function(){

Clone the structure that we're using to wrap var b = a[0].cloneNode(true);

Insert it before the element to be wrapped this.parentNode.insertBefore( b, this );

Find the deepest point in the wrap structure while ( b.firstChild )

b = b.firstChild;

Move the matched element to within the wrap structure b.appendChild( this );

});

},

innerWrap: function() {

The elements to wrap the target around var a = jQuery.clean(arguments);

Wrap each of the matched elements individually return this.each(function(){

Clone the structure that we're using to wrap var b = a[0].cloneNode(true);

Insert it before the element to be wrapped var c = $(this).children(); $(this).children().remove(); this.appendChild(b); $(this).children().prepend(c);

});

},

Change History (2)

comment:1 Changed 13 years ago by brandon

Component: ajaxcore
Description: modified (diff)
Priority: majorminor
Type: bugenhancement

There are several existing innerWrap methods already in use. Here is my recent take on an innerWrap method: http://blog.brandonaaron.net/2007/06/04/jquery-snippets-innerwrap/

comment:2 Changed 13 years ago by john

Milestone: 1.1.31.2
Resolution: fixed
Status: newclosed
Type: enhancementfeature
Version: 1.1.21.1.4

Fixed in SVN rev [3021].

Note: See TracTickets for help on using tickets.