Fixed the issues with .text() working incorrectly.
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery @VERSION - New Wave Javascript
3  *
4  * Copyright (c) 2006 John Resig (jquery.com)
5  * Dual licensed under the MIT (MIT-LICENSE.txt)
6  * and GPL (GPL-LICENSE.txt) licenses.
7  *
8  * $Date$
9  * $Rev$
10  */
11
12 // Global undefined variable
13 window.undefined = window.undefined;
14
15 /**
16  * Create a new jQuery Object
17  *
18  * @constructor
19  * @private
20  * @name jQuery
21  * @param String|Function|Element|Array<Element>|jQuery a selector
22  * @param jQuery|Element|Array<Element> c context
23  * @cat Core
24  */
25 var jQuery = function(a,c) {
26         // If the context is global, return a new object
27         if ( window == this )
28                 return new jQuery(a,c);
29
30         // Make sure that a selection was provided
31         a = a || document;
32         
33         // HANDLE: $(function)
34         // Shortcut for document ready
35         // Safari reports typeof on DOM NodeLists as a function
36         if ( jQuery.isFunction(a) && !a.nodeType && a[0] == undefined )
37                 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
38         
39         // Handle HTML strings
40         if ( typeof a  == "string" ) {
41                 // HANDLE: $(html) -> $(array)
42                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
43                 if ( m )
44                         a = jQuery.clean( [ m[1] ] );
45                 
46                 // HANDLE: $(expr)
47                 else
48                         return new jQuery( c ).find( a );
49         }
50         
51         return this.setArray(
52                 // HANDLE: $(array)
53                 a.constructor == Array && a ||
54
55                 // HANDLE: $(arraylike)
56                 // Watch for when an array-like object is passed as the selector
57                 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
58
59                 // HANDLE: $(*)
60                 [ a ] );
61 };
62
63 // Map over the $ in case of overwrite
64 if ( typeof $ != "undefined" )
65         jQuery._$ = $;
66         
67 // Map the jQuery namespace to the '$' one
68 var $ = jQuery;
69
70 /**
71  * This function accepts a string containing a CSS or
72  * basic XPath selector which is then used to match a set of elements.
73  *
74  * The core functionality of jQuery centers around this function.
75  * Everything in jQuery is based upon this, or uses this in some way.
76  * The most basic use of this function is to pass in an expression
77  * (usually consisting of CSS or XPath), which then finds all matching
78  * elements.
79  *
80  * By default, $() looks for DOM elements within the context of the
81  * current HTML document.
82  *
83  * @example $("div > p")
84  * @desc Finds all p elements that are children of a div element.
85  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
86  * @result [ <p>two</p> ]
87  *
88  * @example $("input:radio", document.forms[0])
89  * @desc Searches for all inputs of type radio within the first form in the document
90  *
91  * @example $("div", xml.responseXML)
92  * @desc This finds all div elements within the specified XML document.
93  *
94  * @name $
95  * @param String expr An expression to search with
96  * @param Element|jQuery context (optional) A DOM Element, Document or jQuery to use as context
97  * @cat Core
98  * @type jQuery
99  * @see $(Element)
100  * @see $(Element<Array>)
101  */
102  
103 /**
104  * Create DOM elements on-the-fly from the provided String of raw HTML.
105  *
106  * @example $("<div><p>Hello</p></div>").appendTo("#body")
107  * @desc Creates a div element (and all of its contents) dynamically, 
108  * and appends it to the element with the ID of body. Internally, an
109  * element is created and it's innerHTML property set to the given markup.
110  * It is therefore both quite flexible and limited. 
111  *
112  * @name $
113  * @param String html A string of HTML to create on the fly.
114  * @cat Core
115  * @type jQuery
116  * @see appendTo(String)
117  */
118
119 /**
120  * Wrap jQuery functionality around a single or multiple DOM Element(s).
121  *
122  * This function also accepts XML Documents and Window objects
123  * as valid arguments (even though they are not DOM Elements).
124  *
125  * @example $(document).find("div > p")
126  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
127  * @result [ <p>two</p> ]
128  * @desc Same as $("div > p") because the document
129  *
130  * @example $(document.body).background( "black" );
131  * @desc Sets the background color of the page to black.
132  *
133  * @example $( myForm.elements ).hide()
134  * @desc Hides all the input elements within a form
135  *
136  * @name $
137  * @param Element|Array<Element> elems DOM element(s) to be encapsulated by a jQuery object.
138  * @cat Core
139  * @type jQuery
140  */
141
142 /**
143  * A shorthand for $(document).ready(), allowing you to bind a function
144  * to be executed when the DOM document has finished loading. This function
145  * behaves just like $(document).ready(), in that it should be used to wrap
146  * all of the other $() operations on your page. While this function is,
147  * technically, chainable - there really isn't much use for chaining against it.
148  * You can have as many $(document).ready events on your page as you like.
149  *
150  * See ready(Function) for details about the ready event. 
151  * 
152  * @example $(function(){
153  *   // Document is ready
154  * });
155  * @desc Executes the function when the DOM is ready to be used.
156  *
157  * @example jQuery(function($) {
158  *   // Your code using failsafe $ alias here...
159  * });
160  * @desc Uses both the shortcut for $(document).ready() and the argument
161  * to write failsafe jQuery code using the $ alias, without relying on the
162  * global alias.
163  *
164  * @name $
165  * @param Function fn The function to execute when the DOM is ready.
166  * @cat Core
167  * @type jQuery
168  * @see ready(Function)
169  */
170
171 jQuery.fn = jQuery.prototype = {
172         /**
173          * The current version of jQuery.
174          *
175          * @private
176          * @property
177          * @name jquery
178          * @type String
179          * @cat Core
180          */
181         jquery: "@VERSION",
182
183         /**
184          * The number of elements currently matched.
185          *
186          * @example $("img").length;
187          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
188          * @result 2
189          *
190          * @property
191          * @name length
192          * @type Number
193          * @cat Core
194          */
195
196         /**
197          * The number of elements currently matched.
198          *
199          * @example $("img").size();
200          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
201          * @result 2
202          *
203          * @name size
204          * @type Number
205          * @cat Core
206          */
207         size: function() {
208                 return this.length;
209         },
210         
211         length: 0,
212
213         /**
214          * Access all matched elements. This serves as a backwards-compatible
215          * way of accessing all matched elements (other than the jQuery object
216          * itself, which is, in fact, an array of elements).
217          *
218          * @example $("img").get();
219          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
220          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
221          * @desc Selects all images in the document and returns the DOM Elements as an Array
222          *
223          * @name get
224          * @type Array<Element>
225          * @cat Core
226          */
227
228         /**
229          * Access a single matched element. num is used to access the
230          * Nth element matched.
231          *
232          * @example $("img").get(0);
233          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
234          * @result [ <img src="test1.jpg"/> ]
235          * @desc Selects all images in the document and returns the first one
236          *
237          * @name get
238          * @type Element
239          * @param Number num Access the element in the Nth position.
240          * @cat Core
241          */
242         get: function( num ) {
243                 return num == undefined ?
244
245                         // Return a 'clean' array
246                         jQuery.makeArray( this ) :
247
248                         // Return just the object
249                         this[num];
250         },
251         
252         /**
253          * Set the jQuery object to an array of elements, while maintaining
254          * the stack.
255          *
256          * @example $("img").pushStack([ document.body ]);
257          * @result $("img").pushStack() == [ document.body ]
258          *
259          * @private
260          * @name pushStack
261          * @type jQuery
262          * @param Elements elems An array of elements
263          * @cat Core
264          */
265         pushStack: function( a ) {
266                 var ret = jQuery(this);
267                 ret.prevObject = this;
268                 return ret.setArray( a );
269         },
270         
271         /**
272          * Set the jQuery object to an array of elements. This operation is
273          * completely destructive - be sure to use .pushStack() if you wish to maintain
274          * the jQuery stack.
275          *
276          * @example $("img").setArray([ document.body ]);
277          * @result $("img").setArray() == [ document.body ]
278          *
279          * @private
280          * @name setArray
281          * @type jQuery
282          * @param Elements elems An array of elements
283          * @cat Core
284          */
285         setArray: function( a ) {
286                 this.length = 0;
287                 [].push.apply( this, a );
288                 return this;
289         },
290
291         /**
292          * Execute a function within the context of every matched element.
293          * This means that every time the passed-in function is executed
294          * (which is once for every element matched) the 'this' keyword
295          * points to the specific element.
296          *
297          * Additionally, the function, when executed, is passed a single
298          * argument representing the position of the element in the matched
299          * set.
300          *
301          * @example $("img").each(function(i){
302          *   this.src = "test" + i + ".jpg";
303          * });
304          * @before <img/><img/>
305          * @result <img src="test0.jpg"/><img src="test1.jpg"/>
306          * @desc Iterates over two images and sets their src property
307          *
308          * @name each
309          * @type jQuery
310          * @param Function fn A function to execute
311          * @cat Core
312          */
313         each: function( fn, args ) {
314                 return jQuery.each( this, fn, args );
315         },
316
317         /**
318          * Searches every matched element for the object and returns
319          * the index of the element, if found, starting with zero. 
320          * Returns -1 if the object wasn't found.
321          *
322          * @example $("*").index( $('#foobar')[0] ) 
323          * @before <div id="foobar"><b></b><span id="foo"></span></div>
324          * @result 0
325          * @desc Returns the index for the element with ID foobar
326          *
327          * @example $("*").index( $('#foo')[0] ) 
328          * @before <div id="foobar"><b></b><span id="foo"></span></div>
329          * @result 2
330          * @desc Returns the index for the element with ID foo within another element
331          *
332          * @example $("*").index( $('#bar')[0] ) 
333          * @before <div id="foobar"><b></b><span id="foo"></span></div>
334          * @result -1
335          * @desc Returns -1, as there is no element with ID bar
336          *
337          * @name index
338          * @type Number
339          * @param Element subject Object to search for
340          * @cat Core
341          */
342         index: function( obj ) {
343                 var pos = -1;
344                 this.each(function(i){
345                         if ( this == obj ) pos = i;
346                 });
347                 return pos;
348         },
349
350         /**
351          * Access a property on the first matched element.
352          * This method makes it easy to retrieve a property value
353          * from the first matched element.
354          *
355          * @example $("img").attr("src");
356          * @before <img src="test.jpg"/>
357          * @result test.jpg
358          * @desc Returns the src attribute from the first image in the document.
359          *
360          * @name attr
361          * @type Object
362          * @param String name The name of the property to access.
363          * @cat DOM/Attributes
364          */
365
366         /**
367          * Set a key/value object as properties to all matched elements.
368          *
369          * This serves as the best way to set a large number of properties
370          * on all matched elements.
371          *
372          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
373          * @before <img/>
374          * @result <img src="test.jpg" alt="Test Image"/>
375          * @desc Sets src and alt attributes to all images.
376          *
377          * @name attr
378          * @type jQuery
379          * @param Map properties Key/value pairs to set as object properties.
380          * @cat DOM/Attributes
381          */
382
383         /**
384          * Set a single property to a value, on all matched elements.
385          *
386          * Can compute values provided as ${formula}, see second example.
387          *
388          * Note that you can't set the name property of input elements in IE.
389          * Use $(html) or .append(html) or .html(html) to create elements
390          * on the fly including the name property.
391          *
392          * @example $("img").attr("src","test.jpg");
393          * @before <img/>
394          * @result <img src="test.jpg"/>
395          * @desc Sets src attribute to all images.
396          *
397          * @example $("img").attr("title", "${this.src}");
398          * @before <img src="test.jpg" />
399          * @result <img src="test.jpg" title="test.jpg" />
400          * @desc Sets title attribute from src attribute, a shortcut for attr(String,Function)
401          *
402          * @name attr
403          * @type jQuery
404          * @param String key The name of the property to set.
405          * @param Object value The value to set the property to.
406          * @cat DOM/Attributes
407          */
408          
409         /**
410          * Set a single property to a computed value, on all matched elements.
411          *
412          * Instead of a value, a function is provided, that computes the value.
413          *
414          * @example $("img").attr("title", function() { return this.src });
415          * @before <img src="test.jpg" />
416          * @result <img src="test.jpg" title="test.jpg" />
417          * @desc Sets title attribute from src attribute.
418          *
419          * @name attr
420          * @type jQuery
421          * @param String key The name of the property to set.
422          * @param Function value A function returning the value to set.
423          * @cat DOM/Attributes
424          */
425         attr: function( key, value, type ) {
426                 var obj = key;
427                 
428                 // Look for the case where we're accessing a style value
429                 if ( key.constructor == String )
430                         if ( value == undefined )
431                                 return jQuery[ type || "attr" ]( this[0], key );
432                         else {
433                                 obj = {};
434                                 obj[ key ] = value;
435                         }
436                 
437                 // Check to see if we're setting style values
438                 return this.each(function(){
439                         // Set all the styles
440                         for ( var prop in obj )
441                                 jQuery.attr(
442                                         type ? this.style : this,
443                                         prop, jQuery.prop(this, obj[prop], type)
444                                 );
445                 });
446         },
447
448         /**
449          * Access a style property on the first matched element.
450          * This method makes it easy to retrieve a style property value
451          * from the first matched element.
452          *
453          * @example $("p").css("color");
454          * @before <p style="color:red;">Test Paragraph.</p>
455          * @result "red"
456          * @desc Retrieves the color style of the first paragraph
457          *
458          * @example $("p").css("font-weight");
459          * @before <p style="font-weight: bold;">Test Paragraph.</p>
460          * @result "bold"
461          * @desc Retrieves the font-weight style of the first paragraph.
462          *
463          * @name css
464          * @type String
465          * @param String name The name of the property to access.
466          * @cat CSS
467          */
468
469         /**
470          * Set a key/value object as style properties to all matched elements.
471          *
472          * This serves as the best way to set a large number of style properties
473          * on all matched elements.
474          *
475          * @example $("p").css({ color: "red", background: "blue" });
476          * @before <p>Test Paragraph.</p>
477          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
478          * @desc Sets color and background styles to all p elements.
479          *
480          * @name css
481          * @type jQuery
482          * @param Map properties Key/value pairs to set as style properties.
483          * @cat CSS
484          */
485
486         /**
487          * Set a single style property to a value, on all matched elements.
488          * If a number is provided, it is automatically converted into a pixel value.
489          *
490          * @example $("p").css("color","red");
491          * @before <p>Test Paragraph.</p>
492          * @result <p style="color:red;">Test Paragraph.</p>
493          * @desc Changes the color of all paragraphs to red
494          *
495          * @example $("p").css("left",30);
496          * @before <p>Test Paragraph.</p>
497          * @result <p style="left:30px;">Test Paragraph.</p>
498          * @desc Changes the left of all paragraphs to "30px"
499          *
500          * @name css
501          * @type jQuery
502          * @param String key The name of the property to set.
503          * @param String|Number value The value to set the property to.
504          * @cat CSS
505          */
506         css: function( key, value ) {
507                 return this.attr( key, value, "curCSS" );
508         },
509
510         /**
511          * Get the text contents of all matched elements. The result is
512          * a string that contains the combined text contents of all matched
513          * elements. This method works on both HTML and XML documents.
514          *
515          * @example $("p").text();
516          * @before <p><b>Test</b> Paragraph.</p><p>Paraparagraph</p>
517          * @result Test Paragraph.Paraparagraph
518          * @desc Gets the concatenated text of all paragraphs
519          *
520          * @name text
521          * @type String
522          * @cat DOM/Attributes
523          */
524
525         /**
526          * Set the text contents of all matched elements.
527          *
528          * Similar to html(), but escapes HTML (replace "<" and ">" with their
529          * HTML entities).
530          *
531          * @example $("p").text("<b>Some</b> new text.");
532          * @before <p>Test Paragraph.</p>
533          * @result <p>&lt;b&gt;Some&lt;/b&gt; new text.</p>
534          * @desc Sets the text of all paragraphs.
535          *
536          * @example $("p").text("<b>Some</b> new text.", true);
537          * @before <p>Test Paragraph.</p>
538          * @result <p>Some new text.</p>
539          * @desc Sets the text of all paragraphs.
540          *
541          * @name text
542          * @type String
543          * @param String val The text value to set the contents of the element to.
544          * @cat DOM/Attributes
545          */
546         text: function(e) {
547                 if ( typeof e == "string" )
548                         return this.empty().append( document.createTextNode( e ) );
549                 else {
550                         e = e || this;
551                         var t = "";
552                         for ( var j = 0, el = e.length; j < el; j++ ) {
553                                 var r = e[j].childNodes;
554                                 for ( var i = 0, rl = r.length; i < rl; i++ )
555                                         if ( r[i].nodeType != 8 )
556                                                 t += r[i].nodeType != 1 ?
557                                                         r[i].nodeValue : jQuery.fn.text([ r[i] ]);
558                         }
559                         return t;
560                 }
561         },
562
563         /**
564          * Wrap all matched elements with a structure of other elements.
565          * This wrapping process is most useful for injecting additional
566          * stucture into a document, without ruining the original semantic
567          * qualities of a document.
568          *
569          * This works by going through the first element
570          * provided (which is generated, on the fly, from the provided HTML)
571          * and finds the deepest ancestor element within its
572          * structure - it is that element that will en-wrap everything else.
573          *
574          * This does not work with elements that contain text. Any necessary text
575          * must be added after the wrapping is done.
576          *
577          * @example $("p").wrap("<div class='wrap'></div>");
578          * @before <p>Test Paragraph.</p>
579          * @result <div class='wrap'><p>Test Paragraph.</p></div>
580          * 
581          * @name wrap
582          * @type jQuery
583          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
584          * @cat DOM/Manipulation
585          */
586
587         /**
588          * Wrap all matched elements with a structure of other elements.
589          * This wrapping process is most useful for injecting additional
590          * stucture into a document, without ruining the original semantic
591          * qualities of a document.
592          *
593          * This works by going through the first element
594          * provided and finding the deepest ancestor element within its
595          * structure - it is that element that will en-wrap everything else.
596          *
597          * This does not work with elements that contain text. Any necessary text
598          * must be added after the wrapping is done.
599          *
600          * @example $("p").wrap( document.getElementById('content') );
601          * @before <p>Test Paragraph.</p><div id="content"></div>
602          * @result <div id="content"><p>Test Paragraph.</p></div>
603          *
604          * @name wrap
605          * @type jQuery
606          * @param Element elem A DOM element that will be wrapped around the target.
607          * @cat DOM/Manipulation
608          */
609         wrap: function() {
610                 // The elements to wrap the target around
611                 var a = jQuery.clean(arguments);
612
613                 // Wrap each of the matched elements individually
614                 return this.each(function(){
615                         // Clone the structure that we're using to wrap
616                         var b = a[0].cloneNode(true);
617
618                         // Insert it before the element to be wrapped
619                         this.parentNode.insertBefore( b, this );
620
621                         // Find the deepest point in the wrap structure
622                         while ( b.firstChild )
623                                 b = b.firstChild;
624
625                         // Move the matched element to within the wrap structure
626                         b.appendChild( this );
627                 });
628         },
629
630         /**
631          * Append content to the inside of every matched element.
632          *
633          * This operation is similar to doing an appendChild to all the
634          * specified elements, adding them into the document.
635          *
636          * @example $("p").append("<b>Hello</b>");
637          * @before <p>I would like to say: </p>
638          * @result <p>I would like to say: <b>Hello</b></p>
639          * @desc Appends some HTML to all paragraphs.
640          *
641          * @example $("p").append( $("#foo")[0] );
642          * @before <p>I would like to say: </p><b id="foo">Hello</b>
643          * @result <p>I would like to say: <b id="foo">Hello</b></p>
644          * @desc Appends an Element to all paragraphs.
645          *
646          * @example $("p").append( $("b") );
647          * @before <p>I would like to say: </p><b>Hello</b>
648          * @result <p>I would like to say: <b>Hello</b></p>
649          * @desc Appends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
650          *
651          * @name append
652          * @type jQuery
653          * @param <Content> content Content to append to the target
654          * @cat DOM/Manipulation
655          * @see prepend(<Content>)
656          * @see before(<Content>)
657          * @see after(<Content>)
658          */
659         append: function() {
660                 return this.domManip(arguments, true, 1, function(a){
661                         this.appendChild( a );
662                 });
663         },
664
665         /**
666          * Prepend content to the inside of every matched element.
667          *
668          * This operation is the best way to insert elements
669          * inside, at the beginning, of all matched elements.
670          *
671          * @example $("p").prepend("<b>Hello</b>");
672          * @before <p>I would like to say: </p>
673          * @result <p><b>Hello</b>I would like to say: </p>
674          * @desc Prepends some HTML to all paragraphs.
675          *
676          * @example $("p").prepend( $("#foo")[0] );
677          * @before <p>I would like to say: </p><b id="foo">Hello</b>
678          * @result <p><b id="foo">Hello</b>I would like to say: </p>
679          * @desc Prepends an Element to all paragraphs.
680          *      
681          * @example $("p").prepend( $("b") );
682          * @before <p>I would like to say: </p><b>Hello</b>
683          * @result <p><b>Hello</b>I would like to say: </p>
684          * @desc Prepends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
685          *
686          * @name prepend
687          * @type jQuery
688          * @param <Content> content Content to prepend to the target.
689          * @cat DOM/Manipulation
690          * @see append(<Content>)
691          * @see before(<Content>)
692          * @see after(<Content>)
693          */
694         prepend: function() {
695                 return this.domManip(arguments, true, -1, function(a){
696                         this.insertBefore( a, this.firstChild );
697                 });
698         },
699         
700         /**
701          * Insert content before each of the matched elements.
702          *
703          * @example $("p").before("<b>Hello</b>");
704          * @before <p>I would like to say: </p>
705          * @result <b>Hello</b><p>I would like to say: </p>
706          * @desc Inserts some HTML before all paragraphs.
707          *
708          * @example $("p").before( $("#foo")[0] );
709          * @before <p>I would like to say: </p><b id="foo">Hello</b>
710          * @result <b id="foo">Hello</b><p>I would like to say: </p>
711          * @desc Inserts an Element before all paragraphs.
712          *
713          * @example $("p").before( $("b") );
714          * @before <p>I would like to say: </p><b>Hello</b>
715          * @result <b>Hello</b><p>I would like to say: </p>
716          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs.
717          *
718          * @name before
719          * @type jQuery
720          * @param <Content> content Content to insert before each target.
721          * @cat DOM/Manipulation
722          * @see append(<Content>)
723          * @see prepend(<Content>)
724          * @see after(<Content>)
725          */
726         before: function() {
727                 return this.domManip(arguments, false, 1, function(a){
728                         this.parentNode.insertBefore( a, this );
729                 });
730         },
731
732         /**
733          * Insert content after each of the matched elements.
734          *
735          * @example $("p").after("<b>Hello</b>");
736          * @before <p>I would like to say: </p>
737          * @result <p>I would like to say: </p><b>Hello</b>
738          * @desc Inserts some HTML after all paragraphs.
739          *
740          * @example $("p").after( $("#foo")[0] );
741          * @before <b id="foo">Hello</b><p>I would like to say: </p>
742          * @result <p>I would like to say: </p><b id="foo">Hello</b>
743          * @desc Inserts an Element after all paragraphs.
744          *
745          * @example $("p").after( $("b") );
746          * @before <b>Hello</b><p>I would like to say: </p>
747          * @result <p>I would like to say: </p><b>Hello</b>
748          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.
749          *
750          * @name after
751          * @type jQuery
752          * @param <Content> content Content to insert after each target.
753          * @cat DOM/Manipulation
754          * @see append(<Content>)
755          * @see prepend(<Content>)
756          * @see before(<Content>)
757          */
758         after: function() {
759                 return this.domManip(arguments, false, -1, function(a){
760                         this.parentNode.insertBefore( a, this.nextSibling );
761                 });
762         },
763
764         /**
765          * End the most recent 'destructive' operation, reverting the list of matched elements
766          * back to its previous state. After an end operation, the list of matched elements will
767          * revert to the last state of matched elements.
768          *
769          * If there was no destructive operation before, an empty set is returned.
770          *
771          * @example $("p").find("span").end();
772          * @before <p><span>Hello</span>, how are you?</p>
773          * @result [ <p>...</p> ]
774          * @desc Selects all paragraphs, finds span elements inside these, and reverts the
775          * selection back to the paragraphs.
776          *
777          * @name end
778          * @type jQuery
779          * @cat DOM/Traversing
780          */
781         end: function() {
782                 return this.prevObject || jQuery([]);
783         },
784
785         /**
786          * Searches for all elements that match the specified expression.
787          
788          * This method is a good way to find additional descendant
789          * elements with which to process.
790          *
791          * All searching is done using a jQuery expression. The expression can be
792          * written using CSS 1-3 Selector syntax, or basic XPath.
793          *
794          * @example $("p").find("span");
795          * @before <p><span>Hello</span>, how are you?</p>
796          * @result [ <span>Hello</span> ]
797          * @desc Starts with all paragraphs and searches for descendant span
798          * elements, same as $("p span")
799          *
800          * @name find
801          * @type jQuery
802          * @param String expr An expression to search with.
803          * @cat DOM/Traversing
804          */
805         find: function(t) {
806                 return this.pushStack( jQuery.map( this, function(a){
807                         return jQuery.find(t,a);
808                 }) );
809         },
810
811         /**
812          * Clone matched DOM Elements and select the clones. 
813          *
814          * This is useful for moving copies of the elements to another
815          * location in the DOM.
816          *
817          * @example $("b").clone().prependTo("p");
818          * @before <b>Hello</b><p>, how are you?</p>
819          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
820          * @desc Clones all b elements (and selects the clones) and prepends them to all paragraphs.
821          *
822          * @name clone
823          * @type jQuery
824          * @param Boolean deep (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself.
825          * @cat DOM/Manipulation
826          */
827         clone: function(deep) {
828                 return this.pushStack( jQuery.map( this, function(a){
829                         return a.cloneNode( deep != undefined ? deep : true );
830                 }) );
831         },
832
833         /**
834          * Removes all elements from the set of matched elements that do not
835          * match the specified expression(s). This method is used to narrow down
836          * the results of a search.
837          *
838          * Provide a comma-separated list of expressions to apply multiple filters at once.
839          *
840          * @example $("p").filter(".selected")
841          * @before <p class="selected">Hello</p><p>How are you?</p>
842          * @result [ <p class="selected">Hello</p> ]
843          * @desc Selects all paragraphs and removes those without a class "selected".
844          *
845          * @example $("p").filter(".selected, :first")
846          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
847          * @result [ <p>Hello</p>, <p class="selected">And Again</p> ]
848          * @desc Selects all paragraphs and removes those without class "selected" and being the first one.
849          *
850          * @name filter
851          * @type jQuery
852          * @param String expression Expression(s) to search with.
853          * @cat DOM/Traversing
854          */
855          
856         /**
857          * Removes all elements from the set of matched elements that do not
858          * pass the specified filter. This method is used to narrow down
859          * the results of a search.
860          *
861          * @example $("p").filter(function(index) {
862          *   return $("ol", this).length == 0;
863          * })
864          * @before <p><ol><li>Hello</li></ol></p><p>How are you?</p>
865          * @result [ <p>How are you?</p> ]
866          * @desc Remove all elements that have a child ol element
867          *
868          * @name filter
869          * @type jQuery
870          * @param Function filter A function to use for filtering
871          * @cat DOM/Traversing
872          */
873         filter: function(t) {
874                 return this.pushStack(
875                         jQuery.isFunction( t ) &&
876                         jQuery.grep(this, function(el, index){
877                                 return t.apply(el, [index])
878                         }) ||
879
880                         jQuery.multiFilter(t,this) );
881         },
882
883         /**
884          * Removes the specified Element from the set of matched elements. This
885          * method is used to remove a single Element from a jQuery object.
886          *
887          * @example $("p").not( $("#selected")[0] )
888          * @before <p>Hello</p><p id="selected">Hello Again</p>
889          * @result [ <p>Hello</p> ]
890          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
891          *
892          * @name not
893          * @type jQuery
894          * @param Element el An element to remove from the set
895          * @cat DOM/Traversing
896          */
897
898         /**
899          * Removes elements matching the specified expression from the set
900          * of matched elements. This method is used to remove one or more
901          * elements from a jQuery object.
902          *
903          * @example $("p").not("#selected")
904          * @before <p>Hello</p><p id="selected">Hello Again</p>
905          * @result [ <p>Hello</p> ]
906          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
907          *
908          * @name not
909          * @type jQuery
910          * @param String expr An expression with which to remove matching elements
911          * @cat DOM/Traversing
912          */
913
914         /**
915          * Removes any elements inside the array of elements from the set
916          * of matched elements. This method is used to remove one or more
917          * elements from a jQuery object.
918          *
919          * @example $("p").not( $("div p.selected") )
920          * @before <div><p>Hello</p><p class="selected">Hello Again</p></div>
921          * @result [ <p>Hello</p> ]
922          * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs.
923          *
924          * @name not
925          * @type jQuery
926          * @param jQuery elems A set of elements to remove from the jQuery set of matched elements.
927          * @cat DOM/Traversing
928          */
929         not: function(t) {
930                 return this.pushStack(
931                         t.constructor == String &&
932                         jQuery.multiFilter(t,this,true) ||
933
934                         jQuery.grep(this,function(a){
935                                         if ( t.constructor == Array || t.jquery )
936                                                 return jQuery.inArray( t, a ) < 0;
937                                         else
938                                                 return a != t;
939                         }) );
940         },
941
942         /**
943          * Adds more elements, matched by the given expression,
944          * to the set of matched elements.
945          *
946          * @example $("p").add("span")
947          * @before <p>Hello</p><span>Hello Again</span>
948          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
949          *
950          * @name add
951          * @type jQuery
952          * @param String expr An expression whose matched elements are added
953          * @cat DOM/Traversing
954          */
955          
956         /**
957          * Adds more elements, created on the fly, to the set of
958          * matched elements.
959          *
960          * @example $("p").add("<span>Again</span>")
961          * @before <p>Hello</p>
962          * @result [ <p>Hello</p>, <span>Again</span> ]
963          *
964          * @name add
965          * @type jQuery
966          * @param String html A string of HTML to create on the fly.
967          * @cat DOM/Traversing
968          */
969
970         /**
971          * Adds one or more Elements to the set of matched elements.
972          *
973          * @example $("p").add( document.getElementById("a") )
974          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
975          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
976          *
977          * @example $("p").add( document.forms[0].elements )
978          * @before <p>Hello</p><p><form><input/><button/></form>
979          * @result [ <p>Hello</p>, <input/>, <button/> ]
980          *
981          * @name add
982          * @type jQuery
983          * @param Element|Array<Element> elements One or more Elements to add
984          * @cat DOM/Traversing
985          */
986         add: function(t) {
987                 return this.pushStack( jQuery.merge(
988                         this.get(),
989                         typeof t == "string" ? jQuery(t).get() : t )
990                 );
991         },
992
993         /**
994          * Checks the current selection against an expression and returns true,
995          * if at least one element of the selection fits the given expression.
996          *
997          * Does return false, if no element fits or the expression is not valid.
998          *
999          * filter(String) is used internally, therefore all rules that apply there
1000          * apply here, too.
1001          *
1002          * @example $("input[@type='checkbox']").parent().is("form")
1003          * @before <form><input type="checkbox" /></form>
1004          * @result true
1005          * @desc Returns true, because the parent of the input is a form element
1006          * 
1007          * @example $("input[@type='checkbox']").parent().is("form")
1008          * @before <form><p><input type="checkbox" /></p></form>
1009          * @result false
1010          * @desc Returns false, because the parent of the input is a p element
1011          *
1012          * @name is
1013          * @type Boolean
1014          * @param String expr The expression with which to filter
1015          * @cat DOM/Traversing
1016          */
1017         is: function(expr) {
1018                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1019         },
1020         
1021         /**
1022          * Get the current value of the first matched element.
1023          *
1024          * @example $("input").val();
1025          * @before <input type="text" value="some text"/>
1026          * @result "some text"
1027          *
1028          * @name val
1029          * @type String
1030          * @cat DOM/Attributes
1031          */
1032         
1033         /**
1034          * Set the value of every matched element.
1035          *
1036          * @example $("input").val("test");
1037          * @before <input type="text" value="some text"/>
1038          * @result <input type="text" value="test"/>
1039          *
1040          * @name val
1041          * @type jQuery
1042          * @param String val Set the property to the specified value.
1043          * @cat DOM/Attributes
1044          */
1045         val: function( val ) {
1046                 return val == undefined ?
1047                         ( this.length ? this[0].value : null ) :
1048                         this.attr( "value", val );
1049         },
1050         
1051         /**
1052          * Get the html contents of the first matched element.
1053          * This property is not available on XML documents.
1054          *
1055          * @example $("div").html();
1056          * @before <div><input/></div>
1057          * @result <input/>
1058          *
1059          * @name html
1060          * @type String
1061          * @cat DOM/Attributes
1062          */
1063         
1064         /**
1065          * Set the html contents of every matched element.
1066          * This property is not available on XML documents.
1067          *
1068          * @example $("div").html("<b>new stuff</b>");
1069          * @before <div><input/></div>
1070          * @result <div><b>new stuff</b></div>
1071          *
1072          * @name html
1073          * @type jQuery
1074          * @param String val Set the html contents to the specified value.
1075          * @cat DOM/Attributes
1076          */
1077         html: function( val ) {
1078                 return val == undefined ?
1079                         ( this.length ? this[0].innerHTML : null ) :
1080                         this.empty().append( val );
1081         },
1082         
1083         /**
1084          * @private
1085          * @name domManip
1086          * @param Array args
1087          * @param Boolean table Insert TBODY in TABLEs if one is not found.
1088          * @param Number dir If dir<0, process args in reverse order.
1089          * @param Function fn The function doing the DOM manipulation.
1090          * @type jQuery
1091          * @cat Core
1092          */
1093         domManip: function(args, table, dir, fn){
1094                 var clone = this.length > 1; 
1095                 var a = jQuery.clean(args);
1096                 if ( dir < 0 )
1097                         a.reverse();
1098
1099                 return this.each(function(){
1100                         var obj = this;
1101
1102                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1103                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1104
1105                         for ( var i = 0, al = a.length; i < al; i++ )
1106                                 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1107
1108                 });
1109         }
1110 };
1111
1112 /**
1113  * Extends the jQuery object itself. Can be used to add functions into
1114  * the jQuery namespace and to add plugin methods (plugins).
1115  * 
1116  * @example jQuery.fn.extend({
1117  *   check: function() {
1118  *     return this.each(function() { this.checked = true; });
1119  *   },
1120  *   uncheck: function() {
1121  *     return this.each(function() { this.checked = false; });
1122  *   }
1123  * });
1124  * $("input[@type=checkbox]").check();
1125  * $("input[@type=radio]").uncheck();
1126  * @desc Adds two plugin methods.
1127  *
1128  * @example jQuery.extend({
1129  *   min: function(a, b) { return a < b ? a : b; },
1130  *   max: function(a, b) { return a > b ? a : b; }
1131  * });
1132  * @desc Adds two functions into the jQuery namespace
1133  *
1134  * @name $.extend
1135  * @param Object prop The object that will be merged into the jQuery object
1136  * @type Object
1137  * @cat Core
1138  */
1139
1140 /**
1141  * Extend one object with one or more others, returning the original,
1142  * modified, object. This is a great utility for simple inheritance.
1143  * 
1144  * @example var settings = { validate: false, limit: 5, name: "foo" };
1145  * var options = { validate: true, name: "bar" };
1146  * jQuery.extend(settings, options);
1147  * @result settings == { validate: true, limit: 5, name: "bar" }
1148  * @desc Merge settings and options, modifying settings
1149  *
1150  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1151  * var options = { validate: true, name: "bar" };
1152  * var settings = jQuery.extend({}, defaults, options);
1153  * @result settings == { validate: true, limit: 5, name: "bar" }
1154  * @desc Merge defaults and options, without modifying the defaults
1155  *
1156  * @name $.extend
1157  * @param Object target The object to extend
1158  * @param Object prop1 The object that will be merged into the first.
1159  * @param Object propN (optional) More objects to merge into the first
1160  * @type Object
1161  * @cat JavaScript
1162  */
1163 jQuery.extend = jQuery.fn.extend = function() {
1164         // copy reference to target object
1165         var target = arguments[0],
1166                 a = 1;
1167
1168         // extend jQuery itself if only one argument is passed
1169         if ( arguments.length == 1 ) {
1170                 target = this;
1171                 a = 0;
1172         }
1173         var prop;
1174         while (prop = arguments[a++])
1175                 // Extend the base object
1176                 for ( var i in prop ) target[i] = prop[i];
1177
1178         // Return the modified object
1179         return target;
1180 };
1181
1182 jQuery.extend({
1183         /**
1184          * Run this function to give control of the $ variable back
1185          * to whichever library first implemented it. This helps to make 
1186          * sure that jQuery doesn't conflict with the $ object
1187          * of other libraries.
1188          *
1189          * By using this function, you will only be able to access jQuery
1190          * using the 'jQuery' variable. For example, where you used to do
1191          * $("div p"), you now must do jQuery("div p").
1192          *
1193          * @example jQuery.noConflict();
1194          * // Do something with jQuery
1195          * jQuery("div p").hide();
1196          * // Do something with another library's $()
1197          * $("content").style.display = 'none';
1198          * @desc Maps the original object that was referenced by $ back to $
1199          *
1200          * @example jQuery.noConflict();
1201          * (function($) { 
1202          *   $(function() {
1203          *     // more code using $ as alias to jQuery
1204          *   });
1205          * })(jQuery);
1206          * // other code using $ as an alias to the other library
1207          * @desc Reverts the $ alias and then creates and executes a
1208          * function to provide the $ as a jQuery alias inside the functions
1209          * scope. Inside the function the original $ object is not available.
1210          * This works well for most plugins that don't rely on any other library.
1211          * 
1212          *
1213          * @name $.noConflict
1214          * @type undefined
1215          * @cat Core 
1216          */
1217         noConflict: function() {
1218                 if ( jQuery._$ )
1219                         $ = jQuery._$;
1220         },
1221
1222         isFunction: function( fn ) {
1223                 return fn && typeof fn == "function";
1224         },
1225
1226         /**
1227          * A generic iterator function, which can be used to seemlessly
1228          * iterate over both objects and arrays. This function is not the same
1229          * as $().each() - which is used to iterate, exclusively, over a jQuery
1230          * object. This function can be used to iterate over anything.
1231          *
1232          * The callback has two arguments:the key (objects) or index (arrays) as first
1233          * the first, and the value as the second.
1234          *
1235          * @example $.each( [0,1,2], function(i, n){
1236          *   alert( "Item #" + i + ": " + n );
1237          * });
1238          * @desc This is an example of iterating over the items in an array,
1239          * accessing both the current item and its index.
1240          *
1241          * @example $.each( { name: "John", lang: "JS" }, function(i, n){
1242          *   alert( "Name: " + i + ", Value: " + n );
1243          * });
1244          *
1245          * @desc This is an example of iterating over the properties in an
1246          * Object, accessing both the current item and its key.
1247          *
1248          * @name $.each
1249          * @param Object obj The object, or array, to iterate over.
1250          * @param Function fn The function that will be executed on every object.
1251          * @type Object
1252          * @cat JavaScript
1253          */
1254         // args is for internal usage only
1255         each: function( obj, fn, args ) {
1256                 if ( obj.length == undefined )
1257                         for ( var i in obj )
1258                                 fn.apply( obj[i], args || [i, obj[i]] );
1259                 else
1260                         for ( var i = 0, ol = obj.length; i < ol; i++ )
1261                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1262                 return obj;
1263         },
1264         
1265         prop: function(elem, value, type){
1266                         // Handle executable functions
1267                         if ( jQuery.isFunction( value ) )
1268                                 return value.call( elem );
1269
1270                         // Handle passing in a number to a CSS property
1271                         if ( value.constructor == Number && type == "curCSS" )
1272                                 return value + "px";
1273
1274                         return value;
1275         },
1276
1277         className: {
1278                 // internal only, use addClass("class")
1279                 add: function( elem, c ){
1280                         jQuery.each( c.split(/\s+/), function(i, cur){
1281                                 if ( !jQuery.className.has( elem.className, cur ) )
1282                                         elem.className += ( elem.className ? " " : "" ) + cur;
1283                         });
1284                 },
1285
1286                 // internal only, use removeClass("class")
1287                 remove: function( elem, c ){
1288                         elem.className = c ?
1289                                 jQuery.grep( elem.className.split(/\s+/), function(cur){
1290                                         return !jQuery.className.has( c, cur ); 
1291                                 }).join(" ") : "";
1292                 },
1293
1294                 // internal only, use is(".class")
1295                 has: function( t, c ) {
1296                         t = t.className || t;
1297                         return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
1298                 }
1299         },
1300
1301         /**
1302          * Swap in/out style options.
1303          * @private
1304          */
1305         swap: function(e,o,f) {
1306                 for ( var i in o ) {
1307                         e.style["old"+i] = e.style[i];
1308                         e.style[i] = o[i];
1309                 }
1310                 f.apply( e, [] );
1311                 for ( var i in o )
1312                         e.style[i] = e.style["old"+i];
1313         },
1314
1315         css: function(e,p) {
1316                 if ( p == "height" || p == "width" ) {
1317                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1318
1319                         for ( var i = 0, dl = d.length; i < dl; i++ ) {
1320                                 old["padding" + d[i]] = 0;
1321                                 old["border" + d[i] + "Width"] = 0;
1322                         }
1323
1324                         jQuery.swap( e, old, function() {
1325                                 if (jQuery.css(e,"display") != "none") {
1326                                         oHeight = e.offsetHeight;
1327                                         oWidth = e.offsetWidth;
1328                                 } else {
1329                                         e = jQuery(e.cloneNode(true))
1330                                                 .find(":radio").removeAttr("checked").end()
1331                                                 .css({
1332                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1333                                                 }).appendTo(e.parentNode)[0];
1334
1335                                         var parPos = jQuery.css(e.parentNode,"position");
1336                                         if ( parPos == "" || parPos == "static" )
1337                                                 e.parentNode.style.position = "relative";
1338
1339                                         oHeight = e.clientHeight;
1340                                         oWidth = e.clientWidth;
1341
1342                                         if ( parPos == "" || parPos == "static" )
1343                                                 e.parentNode.style.position = "static";
1344
1345                                         e.parentNode.removeChild(e);
1346                                 }
1347                         });
1348
1349                         return p == "height" ? oHeight : oWidth;
1350                 }
1351
1352                 return jQuery.curCSS( e, p );
1353         },
1354
1355         curCSS: function(elem, prop, force) {
1356                 var ret;
1357                 
1358                 if (prop == "opacity" && jQuery.browser.msie)
1359                         return jQuery.attr(elem.style, "opacity");
1360                         
1361                 if (prop == "float" || prop == "cssFloat")
1362                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1363
1364                 if (!force && elem.style[prop])
1365                         ret = elem.style[prop];
1366
1367                 else if (document.defaultView && document.defaultView.getComputedStyle) {
1368
1369                         if (prop == "cssFloat" || prop == "styleFloat")
1370                                 prop = "float";
1371
1372                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1373                         var cur = document.defaultView.getComputedStyle(elem, null);
1374
1375                         if ( cur )
1376                                 ret = cur.getPropertyValue(prop);
1377                         else if ( prop == "display" )
1378                                 ret = "none";
1379                         else
1380                                 jQuery.swap(elem, { display: "block" }, function() {
1381                                     var c = document.defaultView.getComputedStyle(this, "");
1382                                     ret = c && c.getPropertyValue(prop) || "";
1383                                 });
1384
1385                 } else if (elem.currentStyle) {
1386
1387                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1388                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1389                         
1390                 }
1391
1392                 return ret;
1393         },
1394         
1395         clean: function(a) {
1396                 var r = [];
1397
1398                 for ( var i = 0, al = a.length; i < al; i++ ) {
1399                         var arg = a[i];
1400
1401                         if ( !arg ) continue;
1402
1403                         if ( arg.constructor == Number )
1404                                 arg = arg.toString();
1405                         
1406                          // Convert html string into DOM nodes
1407                         if ( typeof arg == "string" ) {
1408                                 // Trim whitespace, otherwise indexOf won't work as expected
1409                                 var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
1410
1411                                 var wrap =
1412                                          // option or optgroup
1413                                         !s.indexOf("<opt") &&
1414                                         [1, "<select>", "</select>"] ||
1415                                         
1416                                         (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
1417                                         [1, "<table>", "</table>"] ||
1418                                         
1419                                         !s.indexOf("<tr") &&
1420                                         [2, "<table><tbody>", "</tbody></table>"] ||
1421                                         
1422                                         // <thead> matched above
1423                                         (!s.indexOf("<td") || !s.indexOf("<th")) &&
1424                                         [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
1425                                         
1426                                         [0,"",""];
1427
1428                                 // Go to html and back, then peel off extra wrappers
1429                                 div.innerHTML = wrap[1] + s + wrap[2];
1430                                 
1431                                 // Move to the right depth
1432                                 while ( wrap[0]-- )
1433                                         div = div.firstChild;
1434                                 
1435                                 // Remove IE's autoinserted <tbody> from table fragments
1436                                 if ( jQuery.browser.msie ) {
1437                                         
1438                                         // String was a <table>, *may* have spurious <tbody>
1439                                         if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
1440                                                 tb = div.firstChild && div.firstChild.childNodes;
1441                                                 
1442                                         // String was a bare <thead> or <tfoot>
1443                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1444                                                 tb = div.childNodes;
1445
1446                                         for ( var n = tb.length-1; n >= 0 ; --n )
1447                                                 if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1448                                                         tb[n].parentNode.removeChild(tb[n]);
1449                                         
1450                                 }
1451                                 
1452                                 arg = div.childNodes;
1453                         }
1454
1455                         if ( arg.length === 0 )
1456                                 continue;
1457                         
1458                         if ( arg[0] == undefined )
1459                                 r.push( arg );
1460                         else
1461                                 r = jQuery.merge( r, arg );
1462
1463                 }
1464
1465                 return r;
1466         },
1467         
1468         attr: function(elem, name, value){
1469                 var fix = {
1470                         "for": "htmlFor",
1471                         "class": "className",
1472                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1473                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1474                         innerHTML: "innerHTML",
1475                         className: "className",
1476                         value: "value",
1477                         disabled: "disabled",
1478                         checked: "checked",
1479                         readonly: "readOnly",
1480                         selected: "selected"
1481                 };
1482                 
1483                 // IE actually uses filters for opacity ... elem is actually elem.style
1484                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1485                         // IE has trouble with opacity if it does not have layout
1486                         // Force it by setting the zoom level
1487                         elem.zoom = 1; 
1488
1489                         // Set the alpha filter to set the opacity
1490                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1491                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1492
1493                 } else if ( name == "opacity" && jQuery.browser.msie )
1494                         return elem.filter ? 
1495                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1496                 
1497                 // Mozilla doesn't play well with opacity 1
1498                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1499                         value = 0.9999;
1500
1501                 // Certain attributes only work when accessed via the old DOM 0 way
1502                 if ( fix[name] ) {
1503                         if ( value != undefined ) elem[fix[name]] = value;
1504                         return elem[fix[name]];
1505
1506                 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == "FORM" && (name == "action" || name == "method") )
1507                         return elem.getAttributeNode(name).nodeValue;
1508
1509                 // IE elem.getAttribute passes even for style
1510                 else if ( elem.tagName ) {
1511                         if ( value != undefined ) elem.setAttribute( name, value );
1512                         return elem.getAttribute( name );
1513
1514                 } else {
1515                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1516                         if ( value != undefined ) elem[name] = value;
1517                         return elem[name];
1518                 }
1519         },
1520         
1521         /**
1522          * Remove the whitespace from the beginning and end of a string.
1523          *
1524          * @example $.trim("  hello, how are you?  ");
1525          * @result "hello, how are you?"
1526          *
1527          * @name $.trim
1528          * @type String
1529          * @param String str The string to trim.
1530          * @cat JavaScript
1531          */
1532         trim: function(t){
1533                 return t.replace(/^\s+|\s+$/g, "");
1534         },
1535
1536         makeArray: function( a ) {
1537                 var r = [];
1538
1539                 if ( a.constructor != Array )
1540                         for ( var i = 0, al = a.length; i < al; i++ )
1541                                 r.push( a[i] );
1542                 else
1543                         r = a.slice( 0 );
1544
1545                 return r;
1546         },
1547
1548         inArray: function( b, a ) {
1549                 for ( var i = 0, al = a.length; i < al; i++ )
1550                         if ( a[i] == b )
1551                                 return i;
1552                 return -1;
1553         },
1554
1555         /**
1556          * Merge two arrays together, removing all duplicates.
1557          *
1558          * The new array is: All the results from the first array, followed
1559          * by the unique results from the second array.
1560          *
1561          * @example $.merge( [0,1,2], [2,3,4] )
1562          * @result [0,1,2,3,4]
1563          * @desc Merges two arrays, removing the duplicate 2
1564          *
1565          * @example $.merge( [3,2,1], [4,3,2] )
1566          * @result [3,2,1,4]
1567          * @desc Merges two arrays, removing the duplicates 3 and 2
1568          *
1569          * @name $.merge
1570          * @type Array
1571          * @param Array first The first array to merge.
1572          * @param Array second The second array to merge.
1573          * @cat JavaScript
1574          */
1575         merge: function(first, second) {
1576                 var r = [].slice.call( first, 0 );
1577
1578                 // Now check for duplicates between the two arrays
1579                 // and only add the unique items
1580                 for ( var i = 0, sl = second.length; i < sl; i++ )
1581                         // Check for duplicates
1582                         if ( jQuery.inArray( second[i], r ) == -1 )
1583                                 // The item is unique, add it
1584                                 first.push( second[i] );
1585
1586                 return first;
1587         },
1588
1589         /**
1590          * Filter items out of an array, by using a filter function.
1591          *
1592          * The specified function will be passed two arguments: The
1593          * current array item and the index of the item in the array. The
1594          * function must return 'true' to keep the item in the array, 
1595          * false to remove it.
1596          *
1597          * @example $.grep( [0,1,2], function(i){
1598          *   return i > 0;
1599          * });
1600          * @result [1, 2]
1601          *
1602          * @name $.grep
1603          * @type Array
1604          * @param Array array The Array to find items in.
1605          * @param Function fn The function to process each item against.
1606          * @param Boolean inv Invert the selection - select the opposite of the function.
1607          * @cat JavaScript
1608          */
1609         grep: function(elems, fn, inv) {
1610                 // If a string is passed in for the function, make a function
1611                 // for it (a handy shortcut)
1612                 if ( typeof fn == "string" )
1613                         fn = new Function("a","i","return " + fn);
1614
1615                 var result = [];
1616
1617                 // Go through the array, only saving the items
1618                 // that pass the validator function
1619                 for ( var i = 0, el = elems.length; i < el; i++ )
1620                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1621                                 result.push( elems[i] );
1622
1623                 return result;
1624         },
1625
1626         /**
1627          * Translate all items in an array to another array of items.
1628          *
1629          * The translation function that is provided to this method is 
1630          * called for each item in the array and is passed one argument: 
1631          * The item to be translated.
1632          *
1633          * The function can then return the translated value, 'null'
1634          * (to remove the item), or  an array of values - which will
1635          * be flattened into the full array.
1636          *
1637          * @example $.map( [0,1,2], function(i){
1638          *   return i + 4;
1639          * });
1640          * @result [4, 5, 6]
1641          * @desc Maps the original array to a new one and adds 4 to each value.
1642          *
1643          * @example $.map( [0,1,2], function(i){
1644          *   return i > 0 ? i + 1 : null;
1645          * });
1646          * @result [2, 3]
1647          * @desc Maps the original array to a new one and adds 1 to each
1648          * value if it is bigger then zero, otherwise it's removed-
1649          * 
1650          * @example $.map( [0,1,2], function(i){
1651          *   return [ i, i + 1 ];
1652          * });
1653          * @result [0, 1, 1, 2, 2, 3]
1654          * @desc Maps the original array to a new one, each element is added
1655          * with it's original value and the value plus one.
1656          *
1657          * @name $.map
1658          * @type Array
1659          * @param Array array The Array to translate.
1660          * @param Function fn The function to process each item against.
1661          * @cat JavaScript
1662          */
1663         map: function(elems, fn) {
1664                 // If a string is passed in for the function, make a function
1665                 // for it (a handy shortcut)
1666                 if ( typeof fn == "string" )
1667                         fn = new Function("a","return " + fn);
1668
1669                 var result = [], r = [];
1670
1671                 // Go through the array, translating each of the items to their
1672                 // new value (or values).
1673                 for ( var i = 0, el = elems.length; i < el; i++ ) {
1674                         var val = fn(elems[i],i);
1675
1676                         if ( val !== null && val != undefined ) {
1677                                 if ( val.constructor != Array ) val = [val];
1678                                 result = result.concat( val );
1679                         }
1680                 }
1681
1682                 var r = result.length ? [ result[0] ] : [];
1683
1684                 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1685                         for ( var j = 0; j < i; j++ )
1686                                 if ( result[i] == r[j] )
1687                                         continue check;
1688
1689                         r.push( result[i] );
1690                 }
1691
1692                 return r;
1693         }
1694 });
1695
1696 /**
1697  * Contains flags for the useragent, read from navigator.userAgent.
1698  * Available flags are: safari, opera, msie, mozilla
1699  *
1700  * This property is available before the DOM is ready, therefore you can
1701  * use it to add ready events only for certain browsers.
1702  *
1703  * There are situations where object detections is not reliable enough, in that
1704  * cases it makes sense to use browser detection. Simply try to avoid both!
1705  *
1706  * A combination of browser and object detection yields quite reliable results.
1707  *
1708  * @example $.browser.msie
1709  * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1710  *
1711  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1712  * @desc Alerts "this is safari!" only for safari browsers
1713  *
1714  * @property
1715  * @name $.browser
1716  * @type Boolean
1717  * @cat JavaScript
1718  */
1719  
1720 /*
1721  * Whether the W3C compliant box model is being used.
1722  *
1723  * @property
1724  * @name $.boxModel
1725  * @type Boolean
1726  * @cat JavaScript
1727  */
1728 new function() {
1729         var b = navigator.userAgent.toLowerCase();
1730
1731         // Figure out what browser is being used
1732         jQuery.browser = {
1733                 safari: /webkit/.test(b),
1734                 opera: /opera/.test(b),
1735                 msie: /msie/.test(b) && !/opera/.test(b),
1736                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1737         };
1738
1739         // Check to see if the W3C box model is being used
1740         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1741 };
1742
1743 /**
1744  * Get a set of elements containing the unique parents of the matched
1745  * set of elements.
1746  *
1747  * Can be filtered with an optional expressions.
1748  *
1749  * @example $("p").parent()
1750  * @before <div><p>Hello</p><p>Hello</p></div>
1751  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
1752  * @desc Find the parent element of each paragraph.
1753  *
1754  * @example $("p").parent(".selected")
1755  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
1756  * @result [ <div class="selected"><p>Hello Again</p></div> ]
1757  * @desc Find the parent element of each paragraph with a class "selected".
1758  *
1759  * @name parent
1760  * @type jQuery
1761  * @param String expr (optional) An expression to filter the parents with
1762  * @cat DOM/Traversing
1763  */
1764
1765 /**
1766  * Get a set of elements containing the unique ancestors of the matched
1767  * set of elements (except for the root element).
1768  *
1769  * Can be filtered with an optional expressions.
1770  *
1771  * @example $("span").parents()
1772  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1773  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
1774  * @desc Find all parent elements of each span.
1775  *
1776  * @example $("span").parents("p")
1777  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1778  * @result [ <p><span>Hello</span></p> ]
1779  * @desc Find all parent elements of each span that is a paragraph.
1780  *
1781  * @name parents
1782  * @type jQuery
1783  * @param String expr (optional) An expression to filter the ancestors with
1784  * @cat DOM/Traversing
1785  */
1786
1787 /**
1788  * Get a set of elements containing the unique next siblings of each of the
1789  * matched set of elements.
1790  *
1791  * It only returns the very next sibling, not all next siblings.
1792  *
1793  * Can be filtered with an optional expressions.
1794  *
1795  * @example $("p").next()
1796  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
1797  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
1798  * @desc Find the very next sibling of each paragraph.
1799  *
1800  * @example $("p").next(".selected")
1801  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
1802  * @result [ <p class="selected">Hello Again</p> ]
1803  * @desc Find the very next sibling of each paragraph that has a class "selected".
1804  *
1805  * @name next
1806  * @type jQuery
1807  * @param String expr (optional) An expression to filter the next Elements with
1808  * @cat DOM/Traversing
1809  */
1810
1811 /**
1812  * Get a set of elements containing the unique previous siblings of each of the
1813  * matched set of elements.
1814  *
1815  * Can be filtered with an optional expressions.
1816  *
1817  * It only returns the immediately previous sibling, not all previous siblings.
1818  *
1819  * @example $("p").prev()
1820  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1821  * @result [ <div><span>Hello Again</span></div> ]
1822  * @desc Find the very previous sibling of each paragraph.
1823  *
1824  * @example $("p").prev(".selected")
1825  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1826  * @result [ <div><span>Hello</span></div> ]
1827  * @desc Find the very previous sibling of each paragraph that has a class "selected".
1828  *
1829  * @name prev
1830  * @type jQuery
1831  * @param String expr (optional) An expression to filter the previous Elements with
1832  * @cat DOM/Traversing
1833  */
1834
1835 /**
1836  * Get a set of elements containing all of the unique siblings of each of the
1837  * matched set of elements.
1838  *
1839  * Can be filtered with an optional expressions.
1840  *
1841  * @example $("div").siblings()
1842  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1843  * @result [ <p>Hello</p>, <p>And Again</p> ]
1844  * @desc Find all siblings of each div.
1845  *
1846  * @example $("div").siblings(".selected")
1847  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1848  * @result [ <p class="selected">Hello Again</p> ]
1849  * @desc Find all siblings with a class "selected" of each div.
1850  *
1851  * @name siblings
1852  * @type jQuery
1853  * @param String expr (optional) An expression to filter the sibling Elements with
1854  * @cat DOM/Traversing
1855  */
1856
1857 /**
1858  * Get a set of elements containing all of the unique children of each of the
1859  * matched set of elements.
1860  *
1861  * Can be filtered with an optional expressions.
1862  *
1863  * @example $("div").children()
1864  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1865  * @result [ <span>Hello Again</span> ]
1866  * @desc Find all children of each div.
1867  *
1868  * @example $("div").children(".selected")
1869  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
1870  * @result [ <p class="selected">Hello Again</p> ]
1871  * @desc Find all children with a class "selected" of each div.
1872  *
1873  * @name children
1874  * @type jQuery
1875  * @param String expr (optional) An expression to filter the child Elements with
1876  * @cat DOM/Traversing
1877  */
1878 jQuery.each({
1879         parent: "a.parentNode",
1880         parents: "jQuery.parents(a)",
1881         next: "jQuery.nth(a,2,'nextSibling')",
1882         prev: "jQuery.nth(a,2,'previousSibling')",
1883         siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
1884         children: "jQuery.sibling(a.firstChild)"
1885 }, function(i,n){
1886         jQuery.fn[ i ] = function(a) {
1887                 var ret = jQuery.map(this,n);
1888                 if ( a && typeof a == "string" )
1889                         ret = jQuery.multiFilter(a,ret);
1890                 return this.pushStack( ret );
1891         };
1892 });
1893
1894 /**
1895  * Append all of the matched elements to another, specified, set of elements.
1896  * This operation is, essentially, the reverse of doing a regular
1897  * $(A).append(B), in that instead of appending B to A, you're appending
1898  * A to B.
1899  *
1900  * @example $("p").appendTo("#foo");
1901  * @before <p>I would like to say: </p><div id="foo"></div>
1902  * @result <div id="foo"><p>I would like to say: </p></div>
1903  * @desc Appends all paragraphs to the element with the ID "foo"
1904  *
1905  * @name appendTo
1906  * @type jQuery
1907  * @param <Content> content Content to append to the selected element to.
1908  * @cat DOM/Manipulation
1909  * @see append(<Content>)
1910  */
1911
1912 /**
1913  * Prepend all of the matched elements to another, specified, set of elements.
1914  * This operation is, essentially, the reverse of doing a regular
1915  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1916  * A to B.
1917  *
1918  * @example $("p").prependTo("#foo");
1919  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1920  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1921  * @desc Prepends all paragraphs to the element with the ID "foo"
1922  *
1923  * @name prependTo
1924  * @type jQuery
1925  * @param <Content> content Content to prepend to the selected element to.
1926  * @cat DOM/Manipulation
1927  * @see prepend(<Content>)
1928  */
1929
1930 /**
1931  * Insert all of the matched elements before another, specified, set of elements.
1932  * This operation is, essentially, the reverse of doing a regular
1933  * $(A).before(B), in that instead of inserting B before A, you're inserting
1934  * A before B.
1935  *
1936  * @example $("p").insertBefore("#foo");
1937  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1938  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1939  * @desc Same as $("#foo").before("p")
1940  *
1941  * @name insertBefore
1942  * @type jQuery
1943  * @param <Content> content Content to insert the selected element before.
1944  * @cat DOM/Manipulation
1945  * @see before(<Content>)
1946  */
1947
1948 /**
1949  * Insert all of the matched elements after another, specified, set of elements.
1950  * This operation is, essentially, the reverse of doing a regular
1951  * $(A).after(B), in that instead of inserting B after A, you're inserting
1952  * A after B.
1953  *
1954  * @example $("p").insertAfter("#foo");
1955  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1956  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1957  * @desc Same as $("#foo").after("p")
1958  *
1959  * @name insertAfter
1960  * @type jQuery
1961  * @param <Content> content Content to insert the selected element after.
1962  * @cat DOM/Manipulation
1963  * @see after(<Content>)
1964  */
1965
1966 jQuery.each({
1967         appendTo: "append",
1968         prependTo: "prepend",
1969         insertBefore: "before",
1970         insertAfter: "after"
1971 }, function(i,n){
1972         jQuery.fn[ i ] = function(){
1973                 var a = arguments;
1974                 return this.each(function(){
1975                         for ( var j = 0, al = a.length; j < al; j++ )
1976                                 jQuery(a[j])[n]( this );
1977                 });
1978         };
1979 });
1980
1981 /**
1982  * Remove an attribute from each of the matched elements.
1983  *
1984  * @example $("input").removeAttr("disabled")
1985  * @before <input disabled="disabled"/>
1986  * @result <input/>
1987  *
1988  * @name removeAttr
1989  * @type jQuery
1990  * @param String name The name of the attribute to remove.
1991  * @cat DOM/Attributes
1992  */
1993
1994 /**
1995  * Adds the specified class(es) to each of the set of matched elements.
1996  *
1997  * @example $("p").addClass("selected")
1998  * @before <p>Hello</p>
1999  * @result [ <p class="selected">Hello</p> ]
2000  *
2001  * @example $("p").addClass("selected highlight")
2002  * @before <p>Hello</p>
2003  * @result [ <p class="selected highlight">Hello</p> ]
2004  *
2005  * @name addClass
2006  * @type jQuery
2007  * @param String class One or more CSS classes to add to the elements
2008  * @cat DOM/Attributes
2009  * @see removeClass(String)
2010  */
2011
2012 /**
2013  * Removes all or the specified class(es) from the set of matched elements.
2014  *
2015  * @example $("p").removeClass()
2016  * @before <p class="selected">Hello</p>
2017  * @result [ <p>Hello</p> ]
2018  *
2019  * @example $("p").removeClass("selected")
2020  * @before <p class="selected first">Hello</p>
2021  * @result [ <p class="first">Hello</p> ]
2022  *
2023  * @example $("p").removeClass("selected highlight")
2024  * @before <p class="highlight selected first">Hello</p>
2025  * @result [ <p class="first">Hello</p> ]
2026  *
2027  * @name removeClass
2028  * @type jQuery
2029  * @param String class (optional) One or more CSS classes to remove from the elements
2030  * @cat DOM/Attributes
2031  * @see addClass(String)
2032  */
2033
2034 /**
2035  * Adds the specified class if it is not present, removes it if it is
2036  * present.
2037  *
2038  * @example $("p").toggleClass("selected")
2039  * @before <p>Hello</p><p class="selected">Hello Again</p>
2040  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2041  *
2042  * @name toggleClass
2043  * @type jQuery
2044  * @param String class A CSS class with which to toggle the elements
2045  * @cat DOM/Attributes
2046  */
2047
2048 /**
2049  * Removes all matched elements from the DOM. This does NOT remove them from the
2050  * jQuery object, allowing you to use the matched elements further.
2051  *
2052  * Can be filtered with an optional expressions.
2053  *
2054  * @example $("p").remove();
2055  * @before <p>Hello</p> how are <p>you?</p>
2056  * @result how are
2057  *
2058  * @example $("p").remove(".hello");
2059  * @before <p class="hello">Hello</p> how are <p>you?</p>
2060  * @result how are <p>you?</p>
2061  *
2062  * @name remove
2063  * @type jQuery
2064  * @param String expr (optional) A jQuery expression to filter elements by.
2065  * @cat DOM/Manipulation
2066  */
2067
2068 /**
2069  * Removes all child nodes from the set of matched elements.
2070  *
2071  * @example $("p").empty()
2072  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2073  * @result [ <p></p> ]
2074  *
2075  * @name empty
2076  * @type jQuery
2077  * @cat DOM/Manipulation
2078  */
2079
2080 jQuery.each( {
2081         removeAttr: function( key ) {
2082                 jQuery.attr( this, key, "" );
2083                 this.removeAttribute( key );
2084         },
2085         addClass: function(c){
2086                 jQuery.className.add(this,c);
2087         },
2088         removeClass: function(c){
2089                 jQuery.className.remove(this,c);
2090         },
2091         toggleClass: function( c ){
2092                 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2093         },
2094         remove: function(a){
2095                 if ( !a || jQuery.filter( a, [this] ).r.length )
2096                         this.parentNode.removeChild( this );
2097         },
2098         empty: function() {
2099                 while ( this.firstChild )
2100                         this.removeChild( this.firstChild );
2101         }
2102 }, function(i,n){
2103         jQuery.fn[ i ] = function() {
2104                 return this.each( n, arguments );
2105         };
2106 });
2107
2108 /**
2109  * Reduce the set of matched elements to a single element.
2110  * The position of the element in the set of matched elements
2111  * starts at 0 and goes to length - 1.
2112  *
2113  * @example $("p").eq(1)
2114  * @before <p>This is just a test.</p><p>So is this</p>
2115  * @result [ <p>So is this</p> ]
2116  *
2117  * @name eq
2118  * @type jQuery
2119  * @param Number pos The index of the element that you wish to limit to.
2120  * @cat Core
2121  */
2122
2123 /**
2124  * Reduce the set of matched elements to all elements before a given position.
2125  * The position of the element in the set of matched elements
2126  * starts at 0 and goes to length - 1.
2127  *
2128  * @example $("p").lt(1)
2129  * @before <p>This is just a test.</p><p>So is this</p>
2130  * @result [ <p>This is just a test.</p> ]
2131  *
2132  * @name lt
2133  * @type jQuery
2134  * @param Number pos Reduce the set to all elements below this position.
2135  * @cat Core
2136  */
2137
2138 /**
2139  * Reduce the set of matched elements to all elements after a given position.
2140  * The position of the element in the set of matched elements
2141  * starts at 0 and goes to length - 1.
2142  *
2143  * @example $("p").gt(0)
2144  * @before <p>This is just a test.</p><p>So is this</p>
2145  * @result [ <p>So is this</p> ]
2146  *
2147  * @name gt
2148  * @type jQuery
2149  * @param Number pos Reduce the set to all elements after this position.
2150  * @cat Core
2151  */
2152
2153 /**
2154  * Filter the set of elements to those that contain the specified text.
2155  *
2156  * @example $("p").contains("test")
2157  * @before <p>This is just a test.</p><p>So is this</p>
2158  * @result [ <p>This is just a test.</p> ]
2159  *
2160  * @name contains
2161  * @type jQuery
2162  * @param String str The string that will be contained within the text of an element.
2163  * @cat DOM/Traversing
2164  */
2165 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
2166         jQuery.fn[ n ] = function(num,fn) {
2167                 return this.filter( ":" + n + "(" + num + ")", fn );
2168         };
2169 });
2170
2171 /**
2172  * Get the current computed, pixel, width of the first matched element.
2173  *
2174  * @example $("p").width();
2175  * @before <p>This is just a test.</p>
2176  * @result 300
2177  *
2178  * @name width
2179  * @type String
2180  * @cat CSS
2181  */
2182
2183 /**
2184  * Set the CSS width of every matched element. If no explicit unit
2185  * was specified (like 'em' or '%') then "px" is added to the width.
2186  *
2187  * @example $("p").width(20);
2188  * @before <p>This is just a test.</p>
2189  * @result <p style="width:20px;">This is just a test.</p>
2190  *
2191  * @example $("p").width("20em");
2192  * @before <p>This is just a test.</p>
2193  * @result <p style="width:20em;">This is just a test.</p>
2194  *
2195  * @name width
2196  * @type jQuery
2197  * @param String|Number val Set the CSS property to the specified value.
2198  * @cat CSS
2199  */
2200  
2201 /**
2202  * Get the current computed, pixel, height of the first matched element.
2203  *
2204  * @example $("p").height();
2205  * @before <p>This is just a test.</p>
2206  * @result 300
2207  *
2208  * @name height
2209  * @type String
2210  * @cat CSS
2211  */
2212
2213 /**
2214  * Set the CSS width of every matched element. If no explicit unit
2215  * was specified (like 'em' or '%') then "px" is added to the width.
2216  *
2217  * @example $("p").height(20);
2218  * @before <p>This is just a test.</p>
2219  * @result <p style="height:20px;">This is just a test.</p>
2220  *
2221  * @example $("p").height("20em");
2222  * @before <p>This is just a test.</p>
2223  * @result <p style="height:20em;">This is just a test.</p>
2224  *
2225  * @name height
2226  * @type jQuery
2227  * @param String|Number val Set the CSS property to the specified value.
2228  * @cat CSS
2229  */
2230
2231 jQuery.each( [ "height", "width" ], function(i,n){
2232         jQuery.fn[ n ] = function(h) {
2233                 return h == undefined ?
2234                         ( this.length ? jQuery.css( this[0], n ) : null ) :
2235                         this.css( n, h.constructor == String ? h : h + "px" );
2236         };
2237 });