},
wrapAll: function( html ) {
+ if(jQuery.isFunction(html)) {
+ return this.each(function() { jQuery(this).wrapAll(html.call(this)); });
+ }
+
if ( this[0] ) {
// The elements to wrap the target around
var wrap = jQuery( html, this[0].ownerDocument ).clone();
wrap.map(function(){
var elem = this;
- while ( elem.firstChild )
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 )
elem = elem.firstChild;
return elem;