wrap: function() { // The elements to wrap the target around //包装目标元素的元素 var a = jQuery.clean(arguments);
// Wrap each of the matched elements individually returnthis.each(function(){ // Clone the structure that we're using to wrap var b = a[0].cloneNode(true);//选择a[0]元素
// Insert it before the element to be wrapped //在当前元素之前插入包装节点 this.parentNode.insertBefore( b, this );
// Find he deepest point in the wrap structure //找出最深的第一个包装的元素 while ( b.firstChild ) b = b.firstChild;
// Move the matched element to within the wrap structure //把匹配的当前元素移动到包装元素内 b.appendChild( this ); }); }