+ // 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 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 );
+ });
+ },
+
+ /**
+ * Append any number of elements to the inside of all matched elements.
+ * This operation is similar to doing an <tt>appendChild</tt> to all the
+ * specified elements, adding them into the document.
+ *
+ * @example $("p").append("<b>Hello</b>");
+ * @before <p>I would like to say: </p>
+ * @result <p>I would like to say: <b>Hello</b></p>
+ *
+ * @name append
+ * @type jQuery
+ * @any String html A string of HTML, that will be created on the fly and appended to the target.
+ * @any Element elem A DOM element that will be appended.
+ * @any Array<Element> elems An array of elements, all of which will be appended.
+ * @any Object obj Any object, converted to a string, then a text node.
+ */
+ append: function() {
+ return this.domManip(arguments, true, 1, function(a){
+ this.appendChild( a );
+ });
+ },
+
+ /**
+ * Prepend any number of elements to the inside of all matched elements.
+ * This operation is the best way to insert a set of elements inside, at the
+ * beginning, of all the matched element.
+ *
+ * @example $("p").prepend("<b>Hello</b>");
+ * @before <p>, how are you?</p>
+ * @result <p><b>Hello</b>, how are you?</p>
+ *
+ * @name prepend
+ * @type jQuery
+ * @any String html A string of HTML, that will be created on the fly and prepended to the target.
+ * @any Element elem A DOM element that will be prepended.
+ * @any Array<Element> elems An array of elements, all of which will be prepended.
+ * @any Object obj Any object, converted to a string, then a text node.
+ */
+ prepend: function() {
+ return this.domManip(arguments, true, -1, function(a){
+ this.insertBefore( a, this.firstChild );
+ });
+ },
+
+ /**
+ * Insert any number of elements before each of the matched elements.
+ *
+ * @example $("p").before("<b>Hello</b>");
+ * @before <p>how are you?</p>
+ * @result <b>Hello</b><p>how are you?</p>
+ *
+ * @name before
+ * @type jQuery
+ * @any String html A string of HTML, that will be created on the fly and inserted.
+ * @any Element elem A DOM element that will beinserted.
+ * @any Array<Element> elems An array of elements, all of which will be inserted.
+ * @any Object obj Any object, converted to a string, then a text node.
+ */
+ before: function() {
+ return this.domManip(arguments, false, 1, function(a){
+ this.parentNode.insertBefore( a, this );
+ });
+ },
+
+ /**
+ * Insert any number of elements after each of the matched elements.
+ *
+ * @example $("p").after("<p>I'm doing fine.</p>");
+ * @before <p>How are you?</p>
+ * @result <p>How are you?</p><p>I'm doing fine.</p>
+ *
+ * @name after
+ * @type jQuery
+ * @any String html A string of HTML, that will be created on the fly and inserted.
+ * @any Element elem A DOM element that will beinserted.
+ * @any Array<Element> elems An array of elements, all of which will be inserted.
+ * @any Object obj Any object, converted to a string, then a text node.
+ */
+ after: function() {
+ return this.domManip(arguments, false, -1, function(a){
+ this.parentNode.insertBefore( a, this.nextSibling );
+ });
+ },
+
+ /**
+ * End the most recent 'destructive' operation, reverting the list of matched elements
+ * back to its previous state. After an end operation, the list of matched elements will
+ * revert to the last state of matched elements.
+ *
+ * @example $("p").find("span").end();
+ * @before <p><span>Hello</span>, how are you?</p>
+ * @result $("p").find("span").end() == [ <p>...</p> ]
+ *
+ * @name end
+ * @type jQuery
+ */
+ end: function() {
+ return this.get( this.stack.pop() );
+ },
+
+ /**
+ * Searches for all elements that match the specified expression.
+ * This method is the optimal way of finding additional descendant
+ * elements with which to process.
+ *
+ * All searching is done using a jQuery expression. The expression can be
+ * written using CSS 1-3 Selector sytax, or basic XPath.
+ *
+ * @example $("p").find("span");
+ * @before <p><span>Hello</span>, how are you?</p>
+ * @result $("p").find("span") == [ <span>Hello</span> ]
+ *
+ * @name find
+ * @type jQuery
+ * @param String expr An expression to search with.
+ */
+ find: function(t) {
+ return this.pushStack( jQuery.map( this, function(a){
+ return jQuery.find(t,a);
+ }), arguments );
+ },
+
+ filter: function(t) {
+ return t.constructor == Array ?
+ // Multi Filtering
+ this.pushStack( jQuery.map(this,function(a){
+ for ( var i = 0; i < t.length; i++ )
+ if ( jQuery.filter(t[i],[a]).r.length )
+ return a;
+ }), arguments ) :
+
+ this.pushStack( jQuery.filter(t,this).r, arguments );
+ },
+
+ not: function(t) {
+ return this.pushStack( t.constructor == String ?
+ jQuery.filter(t,this,false).r :
+ jQuery.grep(this,function(a){ return a != t; }), arguments );
+ },
+
+ add: function(t) {
+ return this.pushStack( jQuery.merge( this, t.constructor == String ?
+ jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
+ },
+
+ /**
+ * A wrapper function for each() to be used by append and prepend.
+ * Handles cases where you're trying to modify the inner contents of
+ * a table, when you actually need to work with the tbody.
+ *
+ * @member jQuery
+ * @param {String} expr The expression with which to filter
+ * @type Boolean
+ */
+ is: function(expr) {
+ return jQuery.filter(expr,this).r.length > 0;
+ },
+
+ /**
+ *
+ *
+ * @private
+ * @name domManip
+ * @param Array args
+ * @param Boolean table
+ * @param Number int
+ * @param Function fn The function doing the DOM manipulation.
+ * @type jQuery
+ */
+ domManip: function(args, table, dir, fn){
+ var clone = this.size() > 1;
+ var a = jQuery.clean(args);