Bug Tracker

Changes between Initial Version and Version 1 of Ticket #8332, comment 1


Ignore:
Timestamp:
Feb 20, 2011, 7:04:15 PM (9 years ago)
Author:
jitter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8332, comment 1

    initial v1  
    55If you call `.wrapAll()` on a jQuery object all elements in the collection get wrapped with the HTML structure you provided, but that doesn't mean that after the call the collection suddenly changed and now holds the "new" parents of the before wrapped elements. In fact the collection doesn't change at all and still holds the same elements as before so that you can continue chaining methods and make further e.g. modifications to the elements.
    66
    7 In the case of elements attached to the DOM this often goes by unnoticed (especially when you don't have any other methods chained after the wrappAll).
     7In the case of elements attached to the DOM this often goes by unnoticed (especially when you don't have any other methods chained after the wrappAll) as the new parent (parents) are directly inserted into the DOM and you immediately see it worked.
    88
    9 In the case of detached elements (as in your `$("<td></td><td></td><td></td>")`) you need to know this. Because else when you call `.appendTo()` it appends the td's to the target instead of the tr. So you only need to call `.parent()` before the call to ´.appendTo()`.
     9In the case of detached elements (as in your `$("<td></td><td></td><td></td>")`) you need to be aware of this. Because else when you call `.appendTo()` it appends the td's the collections holds to the target, instead of the tr as you intended. So you only need to call `.parent()` before the call to ´.appendTo()`.
    1010
    1111Also check this [http://jsfiddle.net/jitter/wDfem/ test case] which illustrates how `.wrapAll()` works with attached and detached elements