Lots of documentation overhaul - much more documented, cat output works better now.
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery - 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  * @test ok( Array.prototype.push, "Array.push()" );
19  * @test ok( Function.prototype.apply, "Function.apply()" );
20  * @test ok( document.getElementById, "getElementById" );
21  * @test ok( document.getElementsByTagName, "getElementsByTagName" );
22  * @test ok( RegExp, "RegExp" );
23  * @test ok( jQuery, "jQuery" );
24  * @test ok( $, "$()" );
25  *
26  * @constructor
27  * @private
28  * @name jQuery
29  * @cat Core
30  */
31 function jQuery(a,c) {
32
33         // Shortcut for document ready (because $(document).each() is silly)
34         if ( a && a.constructor == Function && jQuery.fn.ready )
35                 return jQuery(document).ready(a);
36
37         // Make sure that a selection was provided
38         a = a || jQuery.context || document;
39
40         // Watch for when a jQuery object is passed as the selector
41         if ( a.jquery )
42                 return jQuery( jQuery.merge( a, [] ) );
43
44         // Watch for when a jQuery object is passed at the context
45         if ( c && c.jquery )
46                 return jQuery( c ).find(a);
47         
48         // If the context is global, return a new object
49         if ( window == this )
50                 return new jQuery(a,c);
51
52         // Handle HTML strings
53         var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
54         if ( m ) a = jQuery.clean( [ m[1] ] );
55
56         // Watch for when an array is passed in
57         this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
58                 // Assume that it is an array of DOM Elements
59                 jQuery.merge( a, [] ) :
60
61                 // Find the matching elements and save them for later
62                 jQuery.find( a, c ) );
63
64   // See if an extra function was provided
65         var fn = arguments[ arguments.length - 1 ];
66         
67         // If so, execute it in context
68         if ( fn && fn.constructor == Function )
69                 this.each(fn);
70 }
71
72 // Map over the $ in case of overwrite
73 if ( typeof $ != "undefined" )
74         jQuery._$ = $;
75         
76 /**
77  * This function accepts a string containing a CSS selector, 
78  * basic XPath, or raw HTML, which is then used to match a set of elements.
79  * The HTML string is different from the traditional selectors in that
80  * it creates the DOM elements representing that HTML string, on the fly,
81  * to be (assumedly) inserted into the document later.
82  *
83  * The core functionality of jQuery centers around this function. 
84  * Everything in jQuery is based upon this, or uses this in some way. 
85  * The most basic use of this function is to pass in an expression 
86  * (usually consisting of CSS or XPath), which then finds all matching 
87  * elements and remembers them for later use.
88  *
89  * By default, $() looks for DOM elements within the context of the 
90  * current HTML document.
91  *
92  * @example $("div > p")
93  * @desc This finds all p elements that are children of a div element.
94  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
95  * @result [ <p>two</p> ]
96  *
97  * @example $("<div><p>Hello</p></div>").appendTo("#body")
98  * @desc Creates a div element (and all of its contents) dynamically, and appends it to the element with the ID of body.
99  *
100  * @name $
101  * @param String expr An expression to search with, or a string of HTML to create on the fly.
102  * @cat Core
103  * @type jQuery
104  */
105  
106 /**
107  * This function accepts a string containing a CSS selector, or
108  * basic XPath, which is then used to match a set of elements with the
109  * context of the specified DOM element, or document
110  *
111  * @example $("div", xml.responseXML)
112  * @desc This finds all div elements within the specified XML document.
113  *
114  * @name $
115  * @param String expr An expression to search with.
116  * @param Element context A DOM Element, or Document, representing the base context.
117  * @cat Core
118  * @type jQuery
119  */
120  
121 /**
122  * Wrap jQuery functionality around a specific DOM Element.
123  * This function also accepts XML Documents and Window objects
124  * as valid arguments (even though they are not DOM Elements).
125  *
126  * @example $(document).find("div > p")
127  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
128  * @result [ <p>two</p> ]
129  *
130  * @example $(document).ready( loaded );
131  * @desc Executes the "loaded" function when the DOM is ready to
132  * be manipulated.
133  *
134  * @name $
135  * @param Element elem A DOM element to be encapsulated by a jQuery object.
136  * @cat Core
137  * @type jQuery
138  */
139  
140 /**
141  * Wrap jQuery functionality around a set of DOM Elements.
142  *
143  * @example $( myForm.elements ).hide()
144  * @desc Hides all the input elements within a form
145  *
146  * @name $
147  * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
148  * @cat Core
149  * @type jQuery
150  */
151  
152 /**
153  * A shorthand for $(document).ready(), allowing you to bind a function
154  * to be executed when the DOM document has finished loading.
155  *
156  * @example $( loaded )
157  * @desc Executes the function "loaded" when the DOM is ready to be used.
158  *
159  * @name $
160  * @param Function fn The function to execute when the DOM is ready.
161  * @cat Core
162  * @type jQuery
163  */
164  
165 /**
166  * A means of creating a duplicate copy of a jQuery object.
167  *
168  * @example var div = $("div");
169  * $( div ).find("p")
170  * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div'.
171  *
172  * @name $
173  * @param jQuery obj The jQuery object to be cloned.
174  * @cat Core
175  * @type jQuery
176  */
177
178 // Map the jQuery namespace to the '$' one
179 var $ = jQuery;
180
181 jQuery.fn = jQuery.prototype = {
182         /**
183          * The current SVN version of jQuery.
184          *
185          * @private
186          * @property
187          * @name jquery
188          * @type String
189          * @cat Core
190          */
191         jquery: "$Rev$",
192         
193         /**
194          * The number of elements currently matched.
195          *
196          * @example $("img").length;
197          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
198          * @result 2
199          *
200          * @test cmpOK( $("div").length, "==", 2, "Get Number of Elements Found" );
201          *
202          * @property
203          * @name length
204          * @type Number
205          * @cat Core
206          */
207         
208         /**
209          * The number of elements currently matched.
210          *
211          * @example $("img").size();
212          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
213          * @result 2
214          *
215          * @test cmpOK( $("div").size(), "==", 2, "Get Number of Elements Found" );
216          *
217          * @name size
218          * @type Number
219          * @cat Core
220          */
221         size: function() {
222                 return this.length;
223         },
224         
225         /**
226          * Access all matched elements. This serves as a backwards-compatible
227          * way of accessing all matched elements (other than the jQuery object
228          * itself, which is, in fact, an array of elements).
229          *
230          * @example $("img").get();
231          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
232          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
233          *
234          * @test isSet( $("div").get(), q("main","foo"), "Get All Elements" );
235          *
236          * @name get
237          * @type Array<Element>
238          * @cat Core
239          */
240          
241         /**
242          * Access a single matched element. num is used to access the 
243          * Nth element matched.
244          *
245          * @example $("img").get(1);
246          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
247          * @result [ <img src="test1.jpg"/> ]
248          *
249          * @test cmpOK( $("div").get(0), "==", document.getElementById("main"), "Get A Single Element" );
250          *
251          * @name get
252          * @type Element
253          * @param Number num Access the element in the Nth position.
254          * @cat Core
255          */
256          
257         /**
258          * Set the jQuery object to an array of elements.
259          *
260          * @example $("img").get([ document.body ]);
261          * @result $("img").get() == [ document.body ]
262          *
263          * @private
264          * @name get
265          * @type jQuery
266          * @param Elements elems An array of elements
267          * @cat Core
268          */
269         get: function( num ) {
270                 // Watch for when an array (of elements) is passed in
271                 if ( num && num.constructor == Array ) {
272
273                         // Use a tricky hack to make the jQuery object
274                         // look and feel like an array
275                         this.length = 0;
276                         [].push.apply( this, num );
277                         
278                         return this;
279                 } else
280                         return num == undefined ?
281
282                                 // Return a 'clean' array
283                                 jQuery.map( this, function(a){ return a } ) :
284
285                                 // Return just the object
286                                 this[num];
287         },
288
289         /**
290          * Execute a function within the context of every matched element.
291          * This means that every time the passed-in function is executed
292          * (which is once for every element matched) the 'this' keyword
293          * points to the specific element.
294          *
295          * Additionally, the function, when executed, is passed a single
296          * argument representing the position of the element in the matched
297          * set.
298          *
299          * @example $("img").each(function(){
300          *   this.src = "test.jpg";
301          * });
302          * @before <img/> <img/>
303          * @result <img src="test.jpg"/> <img src="test.jpg"/>
304          *
305          * @example $("img").each(function(i){
306          *   alert( "Image #" + i + " is " + this );
307          * });
308          * @before <img/> <img/>
309          * @result <img src="test.jpg"/> <img src="test.jpg"/>
310          *
311          * @test var div = $("div");
312          * div.each(function(){this.foo = 'zoo';});
313          * var pass = true;
314          * for ( var i = 0; i < div.size(); i++ ) {
315          *   if ( div.get(i).foo != "zoo" ) pass = false;
316          * }
317          * ok( pass, "Execute a function, Relative" );
318          *
319          * @name each
320          * @type jQuery
321          * @param Function fn A function to execute
322          * @cat Core
323          */
324         each: function( fn, args ) {
325                 return jQuery.each( this, fn, args );
326         },
327
328         index: function( obj ) {
329                 var pos = -1;
330                 this.each(function(i){
331                         if ( this == obj ) pos = i;
332                 });
333                 return pos;
334         },
335         
336         /**
337          * Access a property on the first matched element.
338          * This method makes it easy to retreive a property value
339          * from the first matched element.
340          *
341          * @example $("img").attr("src");
342          * @before <img src="test.jpg"/>
343          * @result test.jpg
344          *
345          * @name attr
346          * @type Object
347          * @param String name The name of the property to access.
348          * @cat DOM
349          */
350          
351         /**
352          * Set a hash of key/value object properties to all matched elements.
353          * This serves as the best way to set a large number of properties
354          * on all matched elements.
355          *
356          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
357          * @before <img/>
358          * @result <img src="test.jpg" alt="Test Image"/>
359          *
360          * @test var pass = true;
361          * $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
362          *   if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
363          * });
364          * ok( pass, "Set Multiple Attributes" );
365          *
366          * @name attr
367          * @type jQuery
368          * @param Hash prop A set of key/value pairs to set as object properties.
369          * @cat DOM
370          */
371          
372         /**
373          * Set a single property to a value, on all matched elements.
374          *
375          * @example $("img").attr("src","test.jpg");
376          * @before <img/>
377          * @result <img src="test.jpg"/>
378          *
379          * @test var div = $("div");
380          * div.attr("foo", "bar");
381          * var pass = true;
382          * for ( var i = 0; i < div.size(); i++ ) {
383          *   if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
384          * }
385          * ok( pass, "Set Attribute" );
386          *
387          * @name attr
388          * @type jQuery
389          * @param String key The name of the property to set.
390          * @param Object value The value to set the property to.
391          * @cat DOM
392          */
393         attr: function( key, value, type ) {
394                 // Check to see if we're setting style values
395                 return key.constructor != String || value != undefined ?
396                         this.each(function(){
397                                 // See if we're setting a hash of styles
398                                 if ( value == undefined )
399                                         // Set all the styles
400                                         for ( var prop in key )
401                                                 jQuery.attr(
402                                                         type ? this.style : this,
403                                                         prop, key[prop]
404                                                 );
405                                 
406                                 // See if we're setting a single key/value style
407                                 else
408                                         jQuery.attr(
409                                                 type ? this.style : this,
410                                                 key, value
411                                         );
412                         }) :
413                         
414                         // Look for the case where we're accessing a style value
415                         jQuery[ type || "attr" ]( this[0], key );
416         },
417
418         /**
419          * Access a style property on the first matched element.
420          * This method makes it easy to retreive a style property value
421          * from the first matched element.
422          *
423          * @example $("p").css("red");
424          * @before <p style="color:red;">Test Paragraph.</p>
425          * @result red
426          *
427          * @name css
428          * @type Object
429          * @param String name The name of the property to access.
430          * @cat CSS
431          */
432          
433         /**
434          * Set a hash of key/value style properties to all matched elements.
435          * This serves as the best way to set a large number of style properties
436          * on all matched elements.
437          *
438          * @example $("p").css({ color: "red", background: "blue" });
439          * @before <p>Test Paragraph.</p>
440          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
441          *
442          * @name css
443          * @type jQuery
444          * @param Hash prop A set of key/value pairs to set as style properties.
445          * @cat CSS
446          */
447          
448         /**
449          * Set a single style property to a value, on all matched elements.
450          *
451          * @example $("p").css("color","red");
452          * @before <p>Test Paragraph.</p>
453          * @result <p style="color:red;">Test Paragraph.</p>
454          *
455          * @name css
456          * @type jQuery
457          * @param String key The name of the property to set.
458          * @param Object value The value to set the property to.
459          * @cat CSS
460          */
461         css: function( key, value ) {
462                 return this.attr( key, value, "curCSS" );
463         },
464         
465         /**
466          * Retreive the text contents of all matched elements. The result is
467          * a string that contains the combined text contents of all matched
468          * elements. This method works on both HTML and XML documents.
469          *
470          * @example $("p").text();
471          * @before <p>Test Paragraph.</p>
472          * @result Test Paragraph.
473          *
474          * @name text
475          * @type String
476          * @cat DOM
477          */
478         text: function(e) {
479                 e = e || this;
480                 var t = "";
481                 for ( var j = 0; j < e.length; j++ ) {
482                         var r = e[j].childNodes;
483                         for ( var i = 0; i < r.length; i++ )
484                                 if ( r[i].nodeType != 8 )
485                                         t += r[i].nodeType != 1 ?
486                                                 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
487                 }
488                 return t;
489         },
490         
491         /**
492          * Wrap all matched elements with a structure of other elements.
493          * This wrapping process is most useful for injecting additional
494          * stucture into a document, without ruining the original semantic
495          * qualities of a document.
496          *
497          * This works by going through the first element 
498          * provided (which is generated, on the fly, from the provided HTML)
499          * and finds the deepest ancestor element within its 
500          * structure - it is that element that will en-wrap everything else.
501          *
502          * @example $("p").wrap("<div class='wrap'></div>");
503          * @before <p>Test Paragraph.</p>
504          * @result <div class='wrap'><p>Test Paragraph.</p></div>
505          *
506          * @name wrap
507          * @type jQuery
508          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
509          * @cat DOM/Manipulation
510          */
511          
512         /**
513          * Wrap all matched elements with a structure of other elements.
514          * This wrapping process is most useful for injecting additional
515          * stucture into a document, without ruining the original semantic
516          * qualities of a document.
517          *
518          * This works by going through the first element 
519          * provided and finding the deepest ancestor element within its 
520          * structure - it is that element that will en-wrap everything else.
521          *
522          * @example $("p").wrap("<div class='wrap'></div>");
523          * @before <p>Test Paragraph.</p>
524          * @result <div class='wrap'><p>Test Paragraph.</p></div>
525          *
526          * @name wrap
527          * @type jQuery
528          * @param Element elem A DOM element that will be wrapped.
529          * @cat DOM/Manipulation
530          */
531         wrap: function() {
532                 // The elements to wrap the target around
533                 var a = jQuery.clean(arguments);
534                 
535                 // Wrap each of the matched elements individually
536                 return this.each(function(){
537                         // Clone the structure that we're using to wrap
538                         var b = a[0].cloneNode(true);
539                         
540                         // Insert it before the element to be wrapped
541                         this.parentNode.insertBefore( b, this );
542                         
543                         // Find he deepest point in the wrap structure
544                         while ( b.firstChild )
545                                 b = b.firstChild;
546                         
547                         // Move the matched element to within the wrap structure
548                         b.appendChild( this );
549                 });
550         },
551         
552         /**
553          * Append any number of elements to the inside of every matched elements,
554          * generated from the provided HTML.
555          * This operation is similar to doing an appendChild to all the 
556          * specified elements, adding them into the document.
557          * 
558          * @example $("p").append("<b>Hello</b>");
559          * @before <p>I would like to say: </p>
560          * @result <p>I would like to say: <b>Hello</b></p>
561          *
562          * @name append
563          * @type jQuery
564          * @param String html A string of HTML, that will be created on the fly and appended to the target.
565          * @cat DOM/Manipulation
566          */
567          
568         /**
569          * Append an element to the inside of all matched elements.
570          * This operation is similar to doing an appendChild to all the 
571          * specified elements, adding them into the document.
572          * 
573          * @example $("p").append( $("#foo")[0] );
574          * @before <p>I would like to say: </p><b id="foo">Hello</b>
575          * @result <p>I would like to say: <b id="foo">Hello</b></p>
576          *
577          * @name append
578          * @type jQuery
579          * @param Element elem A DOM element that will be appended.
580          * @cat DOM/Manipulation
581          */
582          
583         /**
584          * Append any number of elements to the inside of all matched elements.
585          * This operation is similar to doing an appendChild to all the 
586          * specified elements, adding them into the document.
587          * 
588          * @example $("p").append( $("b") );
589          * @before <p>I would like to say: </p><b>Hello</b>
590          * @result <p>I would like to say: <b>Hello</b></p>
591          *
592          * @name append
593          * @type jQuery
594          * @param Array<Element> elems An array of elements, all of which will be appended.
595          * @cat DOM/Manipulation
596          */
597         append: function() {
598                 return this.domManip(arguments, true, 1, function(a){
599                         this.appendChild( a );
600                 });
601         },
602         
603         /**
604          * Prepend any number of elements to the inside of every matched elements,
605          * generated from the provided HTML.
606          * This operation is the best way to insert dynamically created elements 
607          * inside, at the beginning, of all the matched element.
608          * 
609          * @example $("p").prepend("<b>Hello</b>");
610          * @before <p>I would like to say: </p>
611          * @result <p><b>Hello</b>I would like to say: </p>
612          *
613          * @name prepend
614          * @type jQuery
615          * @param String html A string of HTML, that will be created on the fly and appended to the target.
616          * @cat DOM/Manipulation
617          */
618          
619         /**
620          * Append an element to the inside of all matched elements.
621          * This operation is the best way to insert an element inside, at the 
622          * beginning, of all the matched element.
623          * 
624          * @example $("p").prepend( $("#foo")[0] );
625          * @before <p>I would like to say: </p><b id="foo">Hello</b>
626          * @result <p><b id="foo">Hello</b>I would like to say: </p>
627          *
628          * @name prepend
629          * @type jQuery
630          * @param Element elem A DOM element that will be appended.
631          * @cat DOM/Manipulation
632          */
633          
634         /**
635          * Append any number of elements to the inside of all matched elements.
636          * This operation is the best way to insert a set of elements inside, at the 
637          * beginning, of all the matched element.
638          * 
639          * @example $("p").prepend( $("b") );
640          * @before <p>I would like to say: </p><b>Hello</b>
641          * @result <p><b>Hello</b>I would like to say: </p>
642          *
643          * @name prepend
644          * @type jQuery
645          * @param Array<Element> elems An array of elements, all of which will be appended.
646          * @cat DOM/Manipulation
647          */
648         prepend: function() {
649                 return this.domManip(arguments, true, -1, function(a){
650                         this.insertBefore( a, this.firstChild );
651                 });
652         },
653         
654         /**
655          * Insert any number of dynamically generated elements before each of the 
656          * matched elements.
657          * 
658          * @example $("p").before("<b>Hello</b>");
659          * @before <p>I would like to say: </p>
660          * @result <b>Hello</b><p>I would like to say: </p>
661          *
662          * @name before
663          * @type jQuery
664          * @param String html A string of HTML, that will be created on the fly and appended to the target.
665          * @cat DOM/Manipulation
666          */
667          
668         /**
669          * Insert an element before each of the matched elements.
670          * 
671          * @example $("p").before( $("#foo")[0] );
672          * @before <p>I would like to say: </p><b id="foo">Hello</b>
673          * @result <b id="foo">Hello</b><p>I would like to say: </p>
674          *
675          * @name before
676          * @type jQuery
677          * @param Element elem A DOM element that will be appended.
678          * @cat DOM/Manipulation
679          */
680          
681         /**
682          * Insert any number of elements before each of the matched elements.
683          * 
684          * @example $("p").before( $("b") );
685          * @before <p>I would like to say: </p><b>Hello</b>
686          * @result <b>Hello</b><p>I would like to say: </p>
687          *
688          * @name before
689          * @type jQuery
690          * @param Array<Element> elems An array of elements, all of which will be appended.
691          * @cat DOM/Manipulation
692          */
693         before: function() {
694                 return this.domManip(arguments, false, 1, function(a){
695                         this.parentNode.insertBefore( a, this );
696                 });
697         },
698         
699         /**
700          * Insert any number of dynamically generated elements after each of the 
701          * matched elements.
702          * 
703          * @example $("p").after("<b>Hello</b>");
704          * @before <p>I would like to say: </p>
705          * @result <p>I would like to say: </p><b>Hello</b>
706          *
707          * @name after
708          * @type jQuery
709          * @param String html A string of HTML, that will be created on the fly and appended to the target.
710          * @cat DOM/Manipulation
711          */
712          
713         /**
714          * Insert an element after each of the matched elements.
715          * 
716          * @example $("p").after( $("#foo")[0] );
717          * @before <b id="foo">Hello</b><p>I would like to say: </p>
718          * @result <p>I would like to say: </p><b id="foo">Hello</b>
719          *
720          * @name after
721          * @type jQuery
722          * @param Element elem A DOM element that will be appended.
723          * @cat DOM/Manipulation
724          */
725          
726         /**
727          * Insert any number of elements after each of the matched elements.
728          * 
729          * @example $("p").after( $("b") );
730          * @before <b>Hello</b><p>I would like to say: </p>
731          * @result <p>I would like to say: </p><b>Hello</b>
732          *
733          * @name after
734          * @type jQuery
735          * @param Array<Element> elems An array of elements, all of which will be appended.
736          * @cat DOM/Manipulation
737          */
738         after: function() {
739                 return this.domManip(arguments, false, -1, function(a){
740                         this.parentNode.insertBefore( a, this.nextSibling );
741                 });
742         },
743         
744         /**
745          * End the most recent 'destructive' operation, reverting the list of matched elements
746          * back to its previous state. After an end operation, the list of matched elements will 
747          * revert to the last state of matched elements.
748          *
749          * @example $("p").find("span").end();
750          * @before <p><span>Hello</span>, how are you?</p>
751          * @result $("p").find("span").end() == [ <p>...</p> ]
752          *
753          * @name end
754          * @type jQuery
755          * @cat DOM/Traversing
756          */
757         end: function() {
758                 return this.get( this.stack.pop() );
759         },
760         
761         /**
762          * Searches for all elements that match the specified expression.
763          * This method is the optimal way of finding additional descendant
764          * elements with which to process.
765          *
766          * All searching is done using a jQuery expression. The expression can be 
767          * written using CSS 1-3 Selector syntax, or basic XPath.
768          *
769          * @example $("p").find("span");
770          * @before <p><span>Hello</span>, how are you?</p>
771          * @result $("p").find("span") == [ <span>Hello</span> ]
772          *
773          * @name find
774          * @type jQuery
775          * @param String expr An expression to search with.
776          * @cat DOM/Traversing
777          */
778         find: function(t) {
779                 return this.pushStack( jQuery.map( this, function(a){
780                         return jQuery.find(t,a);
781                 }), arguments );
782         },
783
784         clone: function(deep) {
785                 return this.pushStack( jQuery.map( this, function(a){
786                         return a.cloneNode( deep != undefined ? deep : true );
787                 }), arguments );
788         },
789         
790         /**
791          * Removes all elements from the set of matched elements that do not 
792          * match the specified expression. This method is used to narrow down
793          * the results of a search.
794          *
795          * All searching is done using a jQuery expression. The expression
796          * can be written using CSS 1-3 Selector syntax, or basic XPath.
797          * 
798          * @example $("p").filter(".selected")
799          * @before <p class="selected">Hello</p><p>How are you?</p>
800          * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
801          *
802          * @name filter
803          * @type jQuery
804          * @param String expr An expression to search with.
805          * @cat DOM/Traversing
806          */
807
808         /**
809          * Removes all elements from the set of matched elements that do not
810          * match at least one of the expressions passed to the function. This 
811          * method is used when you want to filter the set of matched elements 
812          * through more than one expression.
813          *
814          * Elements will be retained in the jQuery object if they match at
815          * least one of the expressions passed.
816          *
817          * @example $("p").filter([".selected", ":first"])
818          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
819          * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
820          *
821          * @name filter
822          * @type jQuery
823          * @param Array<String> exprs A set of expressions to evaluate against
824          * @cat DOM/Traversing
825          */
826         filter: function(t) {
827                 return this.pushStack(
828                         t.constructor == Array &&
829                         jQuery.map(this,function(a){
830                                 for ( var i = 0; i < t.length; i++ )
831                                         if ( jQuery.filter(t[i],[a]).r.length )
832                                                 return a;
833                         }) ||
834
835                         t.constructor == Boolean &&
836                         ( t ? this.get() : [] ) ||
837
838                         t.constructor == Function &&
839                         jQuery.grep( this, t ) ||
840
841                         jQuery.filter(t,this).r, arguments );
842         },
843         
844         /**
845          * Removes the specified Element from the set of matched elements. This
846          * method is used to remove a single Element from a jQuery object.
847          *
848          * @example $("p").not( document.getElementById("selected") )
849          * @before <p>Hello</p><p id="selected">Hello Again</p>
850          * @result [ <p>Hello</p> ]
851          *
852          * @name not
853          * @type jQuery
854          * @param Element el An element to remove from the set
855          * @cat DOM/Traversing
856          */
857
858         /**
859          * Removes elements matching the specified expression from the set
860          * of matched elements. This method is used to remove one or more
861          * elements from a jQuery object.
862          * 
863          * @example $("p").not("#selected")
864          * @before <p>Hello</p><p id="selected">Hello Again</p>
865          * @result [ <p>Hello</p> ]
866          * @test cmpOK($("#main > p#ap > a").not("#google").length, "==", 2, ".not")
867          *
868          * @name not
869          * @type jQuery
870          * @param String expr An expression with which to remove matching elements
871          * @cat DOM/Traversing
872          */
873         not: function(t) {
874                 return this.pushStack( t.constructor == String ?
875                         jQuery.filter(t,this,false).r :
876                         jQuery.grep(this,function(a){ return a != t; }), arguments );
877         },
878
879         /**
880          * Adds the elements matched by the expression to the jQuery object. This
881          * can be used to concatenate the result sets of two expressions.
882          *
883          * @example $("p").add("span")
884          * @before <p>Hello</p><p><span>Hello Again</span></p>
885          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
886          *
887          * @name add
888          * @type jQuery
889          * @param String expr An expression whose matched elements are added
890          * @cat DOM/Traversing
891          */
892
893         /**
894          * Adds each of the Elements in the array to the set of matched elements.
895          * This is used to add a set of Elements to a jQuery object.
896          *
897          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
898          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
899          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
900          *
901          * @name add
902          * @type jQuery
903          * @param Array<Element> els An array of Elements to add
904          * @cat DOM/Traversing
905          */
906
907         /**
908          * Adds a single Element to the set of matched elements. This is used to
909          * add a single Element to a jQuery object.
910          *
911          * @example $("p").add( document.getElementById("a") )
912          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
913          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
914          *
915          * @name add
916          * @type jQuery
917          * @param Element el An Element to add
918          * @cat DOM/Traversing
919          */
920         add: function(t) {
921                 return this.pushStack( jQuery.merge( this, t.constructor == String ?
922                         jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
923         },
924         
925         /**
926          * A wrapper function for each() to be used by append and prepend.
927          * Handles cases where you're trying to modify the inner contents of
928          * a table, when you actually need to work with the tbody.
929          *
930          * @member jQuery
931          * @param {String} expr The expression with which to filter
932          * @type Boolean
933          * @cat DOM/Traversing
934          */
935         is: function(expr) {
936                 return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0;
937         },
938         
939         /**
940          * 
941          *
942          * @private
943          * @name domManip
944          * @param Array args
945          * @param Boolean table
946          * @param Number int
947          * @param Function fn The function doing the DOM manipulation.
948          * @type jQuery
949          * @cat Core
950          */
951         domManip: function(args, table, dir, fn){
952                 var clone = this.size() > 1;
953                 var a = jQuery.clean(args);
954                 
955                 return this.each(function(){
956                         var obj = this;
957                         
958                         if ( table && this.nodeName == "TABLE" && a[0].nodeName != "THEAD" ) {
959                                 var tbody = this.getElementsByTagName("tbody");
960
961                                 if ( !tbody.length ) {
962                                         obj = document.createElement("tbody");
963                                         this.appendChild( obj );
964                                 } else
965                                         obj = tbody[0];
966                         }
967
968                         for ( var i = ( dir < 0 ? a.length - 1 : 0 );
969                                 i != ( dir < 0 ? dir : a.length ); i += dir ) {
970                                         fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
971                         }
972                 });
973         },
974         
975         /**
976          * 
977          *
978          * @private
979          * @name pushStack
980          * @param Array a
981          * @param Array args
982          * @type jQuery
983          * @cat Core
984          */
985         pushStack: function(a,args) {
986                 var fn = args && args[args.length-1];
987
988                 if ( !fn || fn.constructor != Function ) {
989                         if ( !this.stack ) this.stack = [];
990                         this.stack.push( this.get() );
991                         this.get( a );
992                 } else {
993                         var old = this.get();
994                         this.get( a );
995                         if ( fn.constructor == Function )
996                                 this.each( fn );
997                         this.get( old );
998                 }
999
1000                 return this;
1001         }
1002 };
1003
1004 /**
1005  * 
1006  *
1007  * @private
1008  * @name extend
1009  * @param Object obj
1010  * @type Object
1011  * @cat Core
1012  */
1013  
1014 /**
1015  * Extend one object with another, returning the original,
1016  * modified, object. This is a great utility for simple inheritance.
1017  *
1018  * @name $.extend
1019  * @param Object obj The object to extend
1020  * @param Object prop The object that will be merged into the first.
1021  * @type Object
1022  * @cat Javascript
1023  */
1024 jQuery.extend = jQuery.fn.extend = function(obj,prop) {
1025         if ( !prop ) { prop = obj; obj = this; }
1026         for ( var i in prop ) obj[i] = prop[i];
1027         return obj;
1028 };
1029
1030 jQuery.extend({
1031         /**
1032          * @private
1033          * @name init
1034          * @type undefined
1035          * @cat Core
1036          */
1037         init: function(){
1038                 jQuery.initDone = true;
1039                 
1040                 jQuery.each( jQuery.macros.axis, function(i,n){
1041                         jQuery.fn[ i ] = function(a) {
1042                                 var ret = jQuery.map(this,n);
1043                                 if ( a && a.constructor == String )
1044                                         ret = jQuery.filter(a,ret).r;
1045                                 return this.pushStack( ret, arguments );
1046                         };
1047                 });
1048                 
1049                 jQuery.each( jQuery.macros.to, function(i,n){
1050                         jQuery.fn[ i ] = function(){
1051                                 var a = arguments;
1052                                 return this.each(function(){
1053                                         for ( var j = 0; j < a.length; j++ )
1054                                                 jQuery(a[j])[n]( this );
1055                                 });
1056                         };
1057                 });
1058                 
1059                 jQuery.each( jQuery.macros.each, function(i,n){
1060                         jQuery.fn[ i ] = function() {
1061                                 return this.each( n, arguments );
1062                         };
1063                 });
1064
1065                 jQuery.each( jQuery.macros.filter, function(i,n){
1066                         jQuery.fn[ n ] = function(num,fn) {
1067                                 return this.filter( ":" + n + "(" + num + ")", fn );
1068                         };
1069                 });
1070                 
1071                 jQuery.each( jQuery.macros.attr, function(i,n){
1072                         n = n || i;
1073                         jQuery.fn[ i ] = function(h) {
1074                                 return h == undefined ?
1075                                         this.length ? this[0][n] : null :
1076                                         this.attr( n, h );
1077                         };
1078                 });
1079         
1080                 jQuery.each( jQuery.macros.css, function(i,n){
1081                         jQuery.fn[ n ] = function(h) {
1082                                 return h == undefined ?
1083                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
1084                                         this.css( n, h );
1085                         };
1086                 });
1087         
1088         },
1089         
1090         /**
1091          * A generic iterator function, which can be used to seemlessly
1092          * iterate over both objects and arrays.
1093          *
1094          * @name $.each
1095          * @param Object obj The object, or array, to iterate over.
1096          * @param Object fn The function that will be executed on every object.
1097          * @type Object
1098          * @cat Javascript
1099          */
1100         each: function( obj, fn, args ) {
1101                 if ( obj.length == undefined )
1102                         for ( var i in obj )
1103                                 fn.apply( obj[i], args || [i, obj[i]] );
1104                 else
1105                         for ( var i = 0; i < obj.length; i++ )
1106                                 fn.apply( obj[i], args || [i, obj[i]] );
1107                 return obj;
1108         },
1109         
1110         className: {
1111                 add: function(o,c){
1112                         if (jQuery.className.has(o,c)) return;
1113                         o.className += ( o.className ? " " : "" ) + c;
1114                 },
1115                 remove: function(o,c){
1116                         o.className = !c ? "" :
1117                                 o.className.replace(
1118                                         new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
1119                 },
1120                 has: function(e,a) {
1121                         if ( e.className != undefined )
1122                                 e = e.className;
1123                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
1124                 }
1125         },
1126         
1127         /**
1128          * Swap in/out style options.
1129          * @private
1130          */
1131         swap: function(e,o,f) {
1132                 for ( var i in o ) {
1133                         e.style["old"+i] = e.style[i];
1134                         e.style[i] = o[i];
1135                 }
1136                 f.apply( e, [] );
1137                 for ( var i in o )
1138                         e.style[i] = e.style["old"+i];
1139         },
1140         
1141         css: function(e,p) {
1142                 if ( p == "height" || p == "width" ) {
1143                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1144         
1145                         for ( var i in d ) {
1146                                 old["padding" + d[i]] = 0;
1147                                 old["border" + d[i] + "Width"] = 0;
1148                         }
1149         
1150                         jQuery.swap( e, old, function() {
1151                                 if (jQuery.css(e,"display") != "none") {
1152                                         oHeight = e.offsetHeight;
1153                                         oWidth = e.offsetWidth;
1154                                 } else {
1155                                         e = jQuery(e.cloneNode(true)).css({
1156                                                 visibility: "hidden", position: "absolute", display: "block"
1157                                         }).appendTo(e.parentNode)[0];
1158
1159                                         oHeight = e.clientHeight;
1160                                         oWidth = e.clientWidth;
1161                                         
1162                                         e.parentNode.removeChild(e);
1163                                 }
1164                         });
1165         
1166                         return p == "height" ? oHeight : oWidth;
1167                 } else if ( p == "opacity" && jQuery.browser.msie )
1168                         return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
1169
1170                 return jQuery.curCSS( e, p );
1171         },
1172
1173         curCSS: function(elem, prop, force) {
1174                 var ret;
1175         
1176                 if (!force && elem.style[prop]) {
1177
1178                         ret = elem.style[prop];
1179
1180                 } else if (elem.currentStyle) {
1181
1182                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
1183                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1184
1185                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1186
1187                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1188                         var cur = document.defaultView.getComputedStyle(elem, null);
1189
1190                         if ( cur )
1191                                 ret = cur.getPropertyValue(prop);
1192                         else if ( prop == 'display' )
1193                                 ret = 'none';
1194                         else
1195                                 jQuery.swap(elem, { display: 'block' }, function() {
1196                                         ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1197                                 });
1198
1199                 }
1200                 
1201                 return ret;
1202         },
1203         
1204         clean: function(a) {
1205                 var r = [];
1206                 for ( var i = 0; i < a.length; i++ ) {
1207                         if ( a[i].constructor == String ) {
1208
1209                                 var table = "";
1210         
1211                                 if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
1212                                         table = "thead";
1213                                         a[i] = "<table>" + a[i] + "</table>";
1214                                 } else if ( !a[i].indexOf("<tr") ) {
1215                                         table = "tr";
1216                                         a[i] = "<table>" + a[i] + "</table>";
1217                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
1218                                         table = "td";
1219                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
1220                                 }
1221         
1222                                 var div = document.createElement("div");
1223                                 div.innerHTML = a[i];
1224         
1225                                 if ( table ) {
1226                                         div = div.firstChild;
1227                                         if ( table != "thead" ) div = div.firstChild;
1228                                         if ( table == "td" ) div = div.firstChild;
1229                                 }
1230         
1231                                 for ( var j = 0; j < div.childNodes.length; j++ )
1232                                         r.push( div.childNodes[j] );
1233                                 } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
1234                                         for ( var k = 0; k < a[i].length; k++ )
1235                                                 r.push( a[i][k] );
1236                                 else if ( a[i] !== null )
1237                                         r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
1238                 }
1239                 return r;
1240         },
1241         
1242         expr: {
1243                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1244                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1245                 ":": {
1246                         // Position Checks
1247                         lt: "i<m[3]-0",
1248                         gt: "i>m[3]-0",
1249                         nth: "m[3]-0==i",
1250                         eq: "m[3]-0==i",
1251                         first: "i==0",
1252                         last: "i==r.length-1",
1253                         even: "i%2==0",
1254                         odd: "i%2",
1255                         
1256                         // Child Checks
1257                         "nth-child": "jQuery.sibling(a,m[3]).cur",
1258                         "first-child": "jQuery.sibling(a,0).cur",
1259                         "last-child": "jQuery.sibling(a,0).last",
1260                         "only-child": "jQuery.sibling(a).length==1",
1261                         
1262                         // Parent Checks
1263                         parent: "a.childNodes.length",
1264                         empty: "!a.childNodes.length",
1265                         
1266                         // Text Check
1267                         contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
1268                         
1269                         // Visibility
1270                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1271                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1272                         
1273                         // Form elements
1274                         enabled: "!a.disabled",
1275                         disabled: "a.disabled",
1276                         checked: "a.checked",
1277                         selected: "a.selected"
1278                 },
1279                 ".": "jQuery.className.has(a,m[2])",
1280                 "@": {
1281                         "=": "z==m[4]",
1282                         "!=": "z!=m[4]",
1283                         "^=": "!z.indexOf(m[4])",
1284                         "$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]",
1285                         "*=": "z.indexOf(m[4])>=0",
1286                         "": "z"
1287                 },
1288                 "[": "jQuery.find(m[2],a).length"
1289         },
1290         
1291         token: [
1292                 "\\.\\.|/\\.\\.", "a.parentNode",
1293                 ">|/", "jQuery.sibling(a.firstChild)",
1294                 "\\+", "jQuery.sibling(a).next",
1295                 "~", function(a){
1296                         var r = [];
1297                         var s = jQuery.sibling(a);
1298                         if ( s.n > 0 )
1299                                 for ( var i = s.n; i < s.length; i++ )
1300                                         r.push( s[i] );
1301                         return r;
1302                 }
1303         ],
1304         
1305         /**
1306          *
1307          * @test t( "Element Selector", "div", ["main","foo"] );
1308          * @test t( "Element Selector", "body", ["body"] );
1309          * @test t( "Element Selector", "html", ["html"] );
1310          * @test cmpOK( $("*").size(), ">=", 30, "Element Selector" );
1311          * @test t( "Parent Element", "div div", ["foo"] );
1312          *
1313          * @test t( "ID Selector", "#body", ["body"] );
1314          * @test t( "ID Selector w/ Element", "body#body", ["body"] );
1315          * @test t( "ID Selector w/ Element", "ul#first", [] );
1316          *
1317          * @test t( "Class Selector", ".blog", ["mark","simon"] );
1318          * @test t( "Class Selector", ".blog.link", ["simon"] );
1319          * @test t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
1320          * @test t( "Parent Class Selector", "p .blog", ["mark","simon"] );
1321          *
1322          * @test t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
1323          * @test t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
1324          * @test t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
1325          * @test t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
1326          *
1327          * @test t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
1328          * @test t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
1329          * @test t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
1330          * @test t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
1331          * @test t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
1332          * @test t( "All Children", "code > *", ["anchor1","anchor2"] );
1333          * @test t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
1334          * @test t( "Adjacent", "a + a", ["groups"] );
1335          * @test t( "Adjacent", "a +a", ["groups"] );
1336          * @test t( "Adjacent", "a+ a", ["groups"] );
1337          * @test t( "Adjacent", "a+a", ["groups"] );
1338          * @test t( "Adjacent", "p + p", ["ap","en","sap"] );
1339          * @test t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
1340          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1341          * @test t( "Attribute Exists", "a[@title]", ["google"] );
1342          * @test t( "Attribute Exists", "*[@title]", ["google"] );
1343          * @test t( "Attribute Exists", "[@title]", ["google"] );
1344          * @test t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
1345          * @test t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
1346          * @test t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
1347          * @test t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
1348          * @test t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
1349          * @test t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
1350          *
1351          * @test t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
1352          * @test t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
1353          * @test t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
1354          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1355          * @test t( "Last Child", "p:last-child", ["sap"] );
1356          * @test t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
1357          * @test t( "Empty", "ul:empty", ["firstUL"] );
1358          * @test t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2"] );
1359          * @test t( "Disabled UI Element", "input:disabled", ["text2"] );
1360          * @test t( "Checked UI Element", "input:checked", ["radio2","check1"] );
1361          * @test t( "Text Contains", "a:contains('Google')", ["google","groups"] );
1362          * @test t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
1363          * @test t( "Element Preceded By", "p ~ div", ["foo"] );
1364          * @test t( "Not", "a.blog:not(.link)", ["mark"] );
1365          *
1366          * @test cmpOK( jQuery.find("//*").length, ">=", 30, "All Elements (//*)" );
1367          * @test t( "All Div Elements", "//div", ["main","foo"] );
1368          * @test t( "Absolute Path", "/html/body", ["body"] );
1369          * @test t( "Absolute Path w/ *", "/* /body", ["body"] );
1370          * @test t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
1371          * @test t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
1372          * @test t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
1373          * @test t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
1374          * @test t( "Attribute Exists", "//a[@title]", ["google"] );
1375          * @test t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
1376          * @test t( "Parent Axis", "//p/..", ["main","foo"] );
1377          * @test t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1378          * @test t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1379          * @test t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
1380          *
1381          * @test t( "nth Element", "p:nth(1)", ["ap"] );
1382          * @test t( "First Element", "p:first", ["firstp"] );
1383          * @test t( "Last Element", "p:last", ["first"] );
1384          * @test t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
1385          * @test t( "Odd Elements", "p:odd", ["ap","en","first"] );
1386          * @test t( "Position Equals", "p:eq(1)", ["ap"] );
1387          * @test t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
1388          * @test t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
1389          * @test t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
1390          * @test t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2"] );
1391          * @test t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
1392          *
1393          * @name $.find
1394          * @type Array<Element>
1395          * @private
1396          * @cat Core
1397          */
1398         find: function( t, context ) {
1399                 // Make sure that the context is a DOM Element
1400                 if ( context && context.nodeType == undefined )
1401                         context = null;
1402         
1403                 // Set the correct context (if none is provided)
1404                 context = context || jQuery.context || document;
1405         
1406                 if ( t.constructor != String ) return [t];
1407         
1408                 if ( !t.indexOf("//") ) {
1409                         context = context.documentElement;
1410                         t = t.substr(2,t.length);
1411                 } else if ( !t.indexOf("/") ) {
1412                         context = context.documentElement;
1413                         t = t.substr(1,t.length);
1414                         // FIX Assume the root element is right :(
1415                         if ( t.indexOf("/") >= 1 )
1416                                 t = t.substr(t.indexOf("/"),t.length);
1417                 }
1418         
1419                 var ret = [context];
1420                 var done = [];
1421                 var last = null;
1422         
1423                 while ( t.length > 0 && last != t ) {
1424                         var r = [];
1425                         last = t;
1426         
1427                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1428                         
1429                         var foundToken = false;
1430                         
1431                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1432                                 if ( foundToken ) continue;
1433
1434                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1435                                 var m = re.exec(t);
1436                                 
1437                                 if ( m ) {
1438                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1439                                         t = jQuery.trim( t.replace( re, "" ) );
1440                                         foundToken = true;
1441                                 }
1442                         }
1443                         
1444                         if ( !foundToken ) {
1445                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1446                                         if ( ret[0] == context ) ret.shift();
1447                                         done = jQuery.merge( done, ret );
1448                                         r = ret = [context];
1449                                         t = " " + t.substr(1,t.length);
1450                                 } else {
1451                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1452                                         var m = re2.exec(t);
1453                 
1454                                         if ( m[1] == "#" ) {
1455                                                 // Ummm, should make this work in all XML docs
1456                                                 var oid = document.getElementById(m[2]);
1457                                                 r = ret = oid ? [oid] : [];
1458                                                 t = t.replace( re2, "" );
1459                                         } else {
1460                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1461                 
1462                                                 for ( var i = 0; i < ret.length; i++ )
1463                                                         r = jQuery.merge( r,
1464                                                                 m[2] == "*" ?
1465                                                                         jQuery.getAll(ret[i]) :
1466                                                                         ret[i].getElementsByTagName(m[2])
1467                                                         );
1468                                         }
1469                                 }
1470         
1471                         }
1472
1473                         if ( t ) {
1474                                 var val = jQuery.filter(t,r);
1475                                 ret = r = val.r;
1476                                 t = jQuery.trim(val.t);
1477                         }
1478                 }
1479         
1480                 if ( ret && ret[0] == context ) ret.shift();
1481                 done = jQuery.merge( done, ret );
1482         
1483                 return done;
1484         },
1485         
1486         getAll: function(o,r) {
1487                 r = r || [];
1488                 var s = o.childNodes;
1489                 for ( var i = 0; i < s.length; i++ )
1490                         if ( s[i].nodeType == 1 ) {
1491                                 r.push( s[i] );
1492                                 jQuery.getAll( s[i], r );
1493                         }
1494                 return r;
1495         },
1496         
1497         attr: function(elem, name, value){
1498                 var fix = {
1499                         "for": "htmlFor",
1500                         "class": "className",
1501                         "float": "cssFloat",
1502                         innerHTML: "innerHTML",
1503                         className: "className",
1504                         value: "value",
1505                         disabled: "disabled"
1506                 };
1507
1508                 if ( fix[name] ) {
1509                         if ( value != undefined ) elem[fix[name]] = value;
1510                         return elem[fix[name]];
1511                 } else if ( elem.getAttribute ) {
1512                         if ( value != undefined ) elem.setAttribute( name, value );
1513                         return elem.getAttribute( name, 2 );
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         // The regular expressions that power the parsing engine
1522         parse: [
1523                 // Match: [@value='test'], [@foo]
1524                 [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
1525
1526                 // Match: [div], [div p]
1527                 [ "(\\[)Q\\]", 0 ],
1528
1529                 // Match: :contains('foo')
1530                 [ "(:)S\\(Q\\)", 0 ],
1531
1532                 // Match: :even, :last-chlid
1533                 [ "([:.#]*)S", 0 ]
1534         ],
1535         
1536         filter: function(t,r,not) {
1537                 // Figure out if we're doing regular, or inverse, filtering
1538                 var g = not !== false ? jQuery.grep :
1539                         function(a,f) {return jQuery.grep(a,f,true);};
1540                 
1541                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1542
1543                         var p = jQuery.parse;
1544
1545                         for ( var i = 0; i < p.length; i++ ) {
1546                                 var re = new RegExp( "^" + p[i][0]
1547
1548                                         // Look for a string-like sequence
1549                                         .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
1550
1551                                         // Look for something (optionally) enclosed with quotes
1552                                         .replace( 'Q', " *'?\"?([^'\"]*?)'?\"? *" ), "i" );
1553
1554                                 var m = re.exec( t );
1555
1556                                 if ( m ) {
1557                                         // Re-organize the match
1558                                         if ( p[i][1] )
1559                                                 m = ["", m[1], m[3], m[2], m[4]];
1560
1561                                         // Remove what we just matched
1562                                         t = t.replace( re, "" );
1563
1564                                         break;
1565                                 }
1566                         }
1567         
1568                         // :not() is a special case that can be optomized by
1569                         // keeping it out of the expression list
1570                         if ( m[1] == ":" && m[2] == "not" )
1571                                 r = jQuery.filter(m[3],r,false).r;
1572                         
1573                         // Otherwise, find the expression to execute
1574                         else {
1575                                 var f = jQuery.expr[m[1]];
1576                                 if ( f.constructor != String )
1577                                         f = jQuery.expr[m[1]][m[2]];
1578                                         
1579                                 // Build a custom macro to enclose it
1580                                 eval("f = function(a,i){" + 
1581                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + 
1582                                         "return " + f + "}");
1583                                 
1584                                 // Execute it against the current filter
1585                                 r = g( r, f );
1586                         }
1587                 }
1588         
1589                 // Return an array of filtered elements (r)
1590                 // and the modified expression string (t)
1591                 return { r: r, t: t };
1592         },
1593         
1594         /**
1595          * Remove the whitespace from the beginning and end of a string.
1596          *
1597          * @name $.trim
1598          * @type String
1599          * @param String str The string to trim.
1600          * @cat Javascript
1601          */
1602         trim: function(t){
1603                 return t.replace(/^\s+|\s+$/g, "");
1604         },
1605         
1606         /**
1607          * All ancestors of a given element.
1608          *
1609          * @private
1610          * @name $.parents
1611          * @type Array<Element>
1612          * @param Element elem The element to find the ancestors of.
1613          * @cat DOM/Traversing
1614          */
1615         parents: function( elem ){
1616                 var matched = [];
1617                 var cur = elem.parentNode;
1618                 while ( cur && cur != document ) {
1619                         matched.push( cur );
1620                         cur = cur.parentNode;
1621                 }
1622                 return matched;
1623         },
1624         
1625         /**
1626          * All elements on a specified axis.
1627          *
1628          * @private
1629          * @name $.sibling
1630          * @type Array
1631          * @param Element elem The element to find all the siblings of (including itself).
1632          * @cat DOM/Traversing
1633          */
1634         sibling: function(elem, pos, not) {
1635                 var elems = [];
1636
1637                 var siblings = elem.parentNode.childNodes;
1638                 for ( var i = 0; i < siblings.length; i++ ) {
1639                         if ( not === true && siblings[i] == elem ) continue;
1640
1641                         if ( siblings[i].nodeType == 1 )
1642                                 elems.push( siblings[i] );
1643                         if ( siblings[i] == elem )
1644                                 elems.n = elems.length - 1;
1645                 }
1646
1647                 return jQuery.extend( elems, {
1648                         last: elems.n == elems.length - 1,
1649                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
1650                         prev: elems[elems.n - 1],
1651                         next: elems[elems.n + 1]
1652                 });
1653         },
1654         
1655         /**
1656          * Merge two arrays together, removing all duplicates.
1657          *
1658          * @name $.merge
1659          * @type Array
1660          * @param Array a The first array to merge.
1661          * @param Array b The second array to merge.
1662          * @cat Javascript
1663          */
1664         merge: function(first, second) {
1665                 var result = [];
1666                 
1667                 // Move b over to the new array (this helps to avoid
1668                 // StaticNodeList instances)
1669                 for ( var k = 0; k < first.length; k++ )
1670                         result[k] = first[k];
1671         
1672                 // Now check for duplicates between a and b and only
1673                 // add the unique items
1674                 for ( var i = 0; i < second.length; i++ ) {
1675                         var noCollision = true;
1676                         
1677                         // The collision-checking process
1678                         for ( var j = 0; j < first.length; j++ )
1679                                 if ( second[i] == first[j] )
1680                                         noCollision = false;
1681                                 
1682                         // If the item is unique, add it
1683                         if ( noCollision )
1684                                 result.push( second[i] );
1685                 }
1686         
1687                 return result;
1688         },
1689         
1690         /**
1691          * Remove items that aren't matched in an array. The function passed
1692          * in to this method will be passed two arguments: 'a' (which is the
1693          * array item) and 'i' (which is the index of the item in the array).
1694          *
1695          * @name $.grep
1696          * @type Array
1697          * @param Array array The Array to find items in.
1698          * @param Function fn The function to process each item against.
1699          * @param Boolean inv Invert the selection - select the opposite of the function.
1700          * @cat Javascript
1701          */
1702         grep: function(elems, fn, inv) {
1703                 // If a string is passed in for the function, make a function
1704                 // for it (a handy shortcut)
1705                 if ( fn.constructor == String )
1706                         fn = new Function("a","i","return " + fn);
1707                         
1708                 var result = [];
1709                 
1710                 // Go through the array, only saving the items
1711                 // that pass the validator function
1712                 for ( var i = 0; i < elems.length; i++ )
1713                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1714                                 result.push( elems[i] );
1715                 
1716                 return result;
1717         },
1718         
1719         /**
1720          * Translate all items in array to another array of items. The translation function
1721          * that is provided to this method is passed one argument: 'a' (the item to be 
1722          * translated). If an array is returned, that array is mapped out and merged into
1723          * the full array. Additionally, returning 'null' or 'undefined' will delete the item
1724          * from the array. Both of these changes imply that the size of the array may not
1725          * be the same size upon completion, as it was when it started.
1726          *
1727          * @name $.map
1728          * @type Array
1729          * @param Array array The Array to translate.
1730          * @param Function fn The function to process each item against.
1731          * @cat Javascript
1732          */
1733         map: function(elems, fn) {
1734                 // If a string is passed in for the function, make a function
1735                 // for it (a handy shortcut)
1736                 if ( fn.constructor == String )
1737                         fn = new Function("a","return " + fn);
1738                 
1739                 var result = [];
1740                 
1741                 // Go through the array, translating each of the items to their
1742                 // new value (or values).
1743                 for ( var i = 0; i < elems.length; i++ ) {
1744                         var val = fn(elems[i],i);
1745
1746                         if ( val !== null && val != undefined ) {
1747                                 if ( val.constructor != Array ) val = [val];
1748                                 result = jQuery.merge( result, val );
1749                         }
1750                 }
1751
1752                 return result;
1753         },
1754         
1755         /*
1756          * A number of helper functions used for managing events.
1757          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
1758          */
1759         event: {
1760         
1761                 // Bind an event to an element
1762                 // Original by Dean Edwards
1763                 add: function(element, type, handler) {
1764                         // For whatever reason, IE has trouble passing the window object
1765                         // around, causing it to be cloned in the process
1766                         if ( jQuery.browser.msie && element.setInterval != undefined )
1767                                 element = window;
1768                 
1769                         // Make sure that the function being executed has a unique ID
1770                         if ( !handler.guid )
1771                                 handler.guid = this.guid++;
1772                                 
1773                         // Init the element's event structure
1774                         if (!element.events)
1775                                 element.events = {};
1776                         
1777                         // Get the current list of functions bound to this event
1778                         var handlers = element.events[type];
1779                         
1780                         // If it hasn't been initialized yet
1781                         if (!handlers) {
1782                                 // Init the event handler queue
1783                                 handlers = element.events[type] = {};
1784                                 
1785                                 // Remember an existing handler, if it's already there
1786                                 if (element["on" + type])
1787                                         handlers[0] = element["on" + type];
1788                         }
1789
1790                         // Add the function to the element's handler list
1791                         handlers[handler.guid] = handler;
1792                         
1793                         // And bind the global event handler to the element
1794                         element["on" + type] = this.handle;
1795         
1796                         // Remember the function in a global list (for triggering)
1797                         if (!this.global[type])
1798                                 this.global[type] = [];
1799                         this.global[type].push( element );
1800                 },
1801                 
1802                 guid: 1,
1803                 global: {},
1804                 
1805                 // Detach an event or set of events from an element
1806                 remove: function(element, type, handler) {
1807                         if (element.events)
1808                                 if (type && element.events[type])
1809                                         if ( handler )
1810                                                 delete element.events[type][handler.guid];
1811                                         else
1812                                                 for ( var i in element.events[type] )
1813                                                         delete element.events[type][i];
1814                                 else
1815                                         for ( var j in element.events )
1816                                                 this.remove( element, j );
1817                 },
1818                 
1819                 trigger: function(type,data,element) {
1820                         // Touch up the incoming data
1821                         data = data || [];
1822         
1823                         // Handle a global trigger
1824                         if ( !element ) {
1825                                 var g = this.global[type];
1826                                 if ( g )
1827                                         for ( var i = 0; i < g.length; i++ )
1828                                                 this.trigger( type, data, g[i] );
1829         
1830                         // Handle triggering a single element
1831                         } else if ( element["on" + type] ) {
1832                                 // Pass along a fake event
1833                                 data.unshift( this.fix({ type: type, target: element }) );
1834         
1835                                 // Trigger the event
1836                                 element["on" + type].apply( element, data );
1837                         }
1838                 },
1839                 
1840                 handle: function(event) {
1841                         if ( typeof jQuery == "undefined" ) return;
1842
1843                         event = event || jQuery.event.fix( window.event );
1844         
1845                         // If no correct event was found, fail
1846                         if ( !event ) return;
1847                 
1848                         var returnValue = true;
1849
1850                         var c = this.events[event.type];
1851                 
1852                         for ( var j in c ) {
1853                                 if ( c[j].apply( this, [event] ) === false ) {
1854                                         event.preventDefault();
1855                                         event.stopPropagation();
1856                                         returnValue = false;
1857                                 }
1858                         }
1859                         
1860                         return returnValue;
1861                 },
1862                 
1863                 fix: function(event) {
1864                         if ( event ) {
1865                                 event.preventDefault = function() {
1866                                         this.returnValue = false;
1867                                 };
1868                         
1869                                 event.stopPropagation = function() {
1870                                         this.cancelBubble = true;
1871                                 };
1872                         }
1873                         
1874                         return event;
1875                 }
1876         
1877         }
1878 });
1879
1880 new function() {
1881         var b = navigator.userAgent.toLowerCase();
1882
1883         // Figure out what browser is being used
1884         jQuery.browser = {
1885                 safari: /webkit/.test(b),
1886                 opera: /opera/.test(b),
1887                 msie: /msie/.test(b) && !/opera/.test(b),
1888                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1889         };
1890
1891         // Check to see if the W3C box model is being used
1892         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1893 };
1894
1895 jQuery.macros = {
1896         to: {
1897                 /**
1898                  * Append all of the matched elements to another, specified, set of elements.
1899                  * This operation is, essentially, the reverse of doing a regular
1900                  * $(A).append(B), in that instead of appending B to A, you're appending
1901                  * A to B.
1902                  * 
1903                  * @example $("p").appendTo("#foo");
1904                  * @before <p>I would like to say: </p><div id="foo"></div>
1905                  * @result <div id="foo"><p>I would like to say: </p></div>
1906                  *
1907                  * @name appendTo
1908                  * @type jQuery
1909                  * @param String expr A jQuery expression of elements to match.
1910                  * @cat DOM/Manipulation
1911                  */
1912                 appendTo: "append",
1913                 
1914                 /**
1915                  * Prepend all of the matched elements to another, specified, set of elements.
1916                  * This operation is, essentially, the reverse of doing a regular
1917                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1918                  * A to B.
1919                  * 
1920                  * @example $("p").prependTo("#foo");
1921                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1922                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1923                  *
1924                  * @name prependTo
1925                  * @type jQuery
1926                  * @param String expr A jQuery expression of elements to match.
1927                  * @cat DOM/Manipulation
1928                  */
1929                 prependTo: "prepend",
1930                 
1931                 /**
1932                  * Insert all of the matched elements before another, specified, set of elements.
1933                  * This operation is, essentially, the reverse of doing a regular
1934                  * $(A).before(B), in that instead of inserting B before A, you're inserting
1935                  * A before B.
1936                  * 
1937                  * @example $("p").insertBefore("#foo");
1938                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1939                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1940                  *
1941                  * @name insertBefore
1942                  * @type jQuery
1943                  * @param String expr A jQuery expression of elements to match.
1944                  * @cat DOM/Manipulation
1945                  */
1946                 insertBefore: "before",
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                  *
1958                  * @name insertAfter
1959                  * @type jQuery
1960                  * @param String expr A jQuery expression of elements to match.
1961                  * @cat DOM/Manipulation
1962                  */
1963                 insertAfter: "after"
1964         },
1965         
1966         /**
1967          * Get the current CSS width of the first matched element.
1968          * 
1969          * @example $("p").width();
1970          * @before <p>This is just a test.</p>
1971          * @result "300px"
1972          *
1973          * @name width
1974          * @type String
1975          * @cat CSS
1976          */
1977          
1978         /**
1979          * Set the CSS width of every matched element. Be sure to include
1980          * the "px" (or other unit of measurement) after the number that you 
1981          * specify, otherwise you might get strange results.
1982          * 
1983          * @example $("p").width("20px");
1984          * @before <p>This is just a test.</p>
1985          * @result <p style="width:20px;">This is just a test.</p>
1986          *
1987          * @name width
1988          * @type jQuery
1989          * @param String val Set the CSS property to the specified value.
1990          * @cat CSS
1991          */
1992         
1993         /**
1994          * Get the current CSS height of the first matched element.
1995          * 
1996          * @example $("p").height();
1997          * @before <p>This is just a test.</p>
1998          * @result "14px"
1999          *
2000          * @name height
2001          * @type String
2002          * @cat CSS
2003          */
2004          
2005         /**
2006          * Set the CSS height of every matched element. Be sure to include
2007          * the "px" (or other unit of measurement) after the number that you 
2008          * specify, otherwise you might get strange results.
2009          * 
2010          * @example $("p").height("20px");
2011          * @before <p>This is just a test.</p>
2012          * @result <p style="height:20px;">This is just a test.</p>
2013          *
2014          * @name height
2015          * @type jQuery
2016          * @param String val Set the CSS property to the specified value.
2017          * @cat CSS
2018          */
2019          
2020         /**
2021          * Get the current CSS top of the first matched element.
2022          * 
2023          * @example $("p").top();
2024          * @before <p>This is just a test.</p>
2025          * @result "0px"
2026          *
2027          * @name top
2028          * @type String
2029          * @cat CSS
2030          */
2031          
2032         /**
2033          * Set the CSS top of every matched element. Be sure to include
2034          * the "px" (or other unit of measurement) after the number that you 
2035          * specify, otherwise you might get strange results.
2036          * 
2037          * @example $("p").top("20px");
2038          * @before <p>This is just a test.</p>
2039          * @result <p style="top:20px;">This is just a test.</p>
2040          *
2041          * @name top
2042          * @type jQuery
2043          * @param String val Set the CSS property to the specified value.
2044          * @cat CSS
2045          */
2046          
2047         /**
2048          * Get the current CSS left of the first matched element.
2049          * 
2050          * @example $("p").left();
2051          * @before <p>This is just a test.</p>
2052          * @result "0px"
2053          *
2054          * @name left
2055          * @type String
2056          * @cat CSS
2057          */
2058          
2059         /**
2060          * Set the CSS left of every matched element. Be sure to include
2061          * the "px" (or other unit of measurement) after the number that you 
2062          * specify, otherwise you might get strange results.
2063          * 
2064          * @example $("p").left("20px");
2065          * @before <p>This is just a test.</p>
2066          * @result <p style="left:20px;">This is just a test.</p>
2067          *
2068          * @name left
2069          * @type jQuery
2070          * @param String val Set the CSS property to the specified value.
2071          * @cat CSS
2072          */
2073          
2074         /**
2075          * Get the current CSS position of the first matched element.
2076          * 
2077          * @example $("p").position();
2078          * @before <p>This is just a test.</p>
2079          * @result "static"
2080          *
2081          * @name position
2082          * @type String
2083          * @cat CSS
2084          */
2085          
2086         /**
2087          * Set the CSS position of every matched element.
2088          * 
2089          * @example $("p").position("relative");
2090          * @before <p>This is just a test.</p>
2091          * @result <p style="position:relative;">This is just a test.</p>
2092          *
2093          * @name position
2094          * @type jQuery
2095          * @param String val Set the CSS property to the specified value.
2096          * @cat CSS
2097          */
2098          
2099         /**
2100          * Get the current CSS float of the first matched element.
2101          * 
2102          * @example $("p").float();
2103          * @before <p>This is just a test.</p>
2104          * @result "none"
2105          *
2106          * @name float
2107          * @type String
2108          * @cat CSS
2109          */
2110          
2111         /**
2112          * Set the CSS float of every matched element.
2113          * 
2114          * @example $("p").float("left");
2115          * @before <p>This is just a test.</p>
2116          * @result <p style="float:left;">This is just a test.</p>
2117          *
2118          * @name float
2119          * @type jQuery
2120          * @param String val Set the CSS property to the specified value.
2121          * @cat CSS
2122          */
2123          
2124         /**
2125          * Get the current CSS overflow of the first matched element.
2126          * 
2127          * @example $("p").overflow();
2128          * @before <p>This is just a test.</p>
2129          * @result "none"
2130          *
2131          * @name overflow
2132          * @type String
2133          * @cat CSS
2134          */
2135          
2136         /**
2137          * Set the CSS overflow of every matched element.
2138          * 
2139          * @example $("p").overflow("auto");
2140          * @before <p>This is just a test.</p>
2141          * @result <p style="overflow:auto;">This is just a test.</p>
2142          *
2143          * @name overflow
2144          * @type jQuery
2145          * @param String val Set the CSS property to the specified value.
2146          * @cat CSS
2147          */
2148          
2149         /**
2150          * Get the current CSS color of the first matched element.
2151          * 
2152          * @example $("p").color();
2153          * @before <p>This is just a test.</p>
2154          * @result "black"
2155          *
2156          * @name color
2157          * @type String
2158          * @cat CSS
2159          */
2160          
2161         /**
2162          * Set the CSS color of every matched element.
2163          * 
2164          * @example $("p").color("blue");
2165          * @before <p>This is just a test.</p>
2166          * @result <p style="color:blue;">This is just a test.</p>
2167          *
2168          * @name color
2169          * @type jQuery
2170          * @param String val Set the CSS property to the specified value.
2171          * @cat CSS
2172          */
2173          
2174         /**
2175          * Get the current CSS background of the first matched element.
2176          * 
2177          * @example $("p").background();
2178          * @before <p>This is just a test.</p>
2179          * @result ""
2180          *
2181          * @name background
2182          * @type String
2183          * @cat CSS
2184          */
2185          
2186         /**
2187          * Set the CSS background of every matched element.
2188          * 
2189          * @example $("p").background("blue");
2190          * @before <p>This is just a test.</p>
2191          * @result <p style="background:blue;">This is just a test.</p>
2192          *
2193          * @name background
2194          * @type jQuery
2195          * @param String val Set the CSS property to the specified value.
2196          * @cat CSS
2197          */
2198         
2199         css: "width,height,top,left,position,float,overflow,color,background".split(","),
2200
2201         filter: [ "eq", "lt", "gt", "contains" ],
2202
2203         attr: {
2204                 /**
2205                  * Get the current value of the first matched element.
2206                  * 
2207                  * @example $("input").val();
2208                  * @before <input type="text" value="some text"/>
2209                  * @result "some text"
2210                  *
2211                  * @name val
2212                  * @type String
2213                  * @cat DOM/Attributes
2214                  */
2215                  
2216                 /**
2217                  * Set the value of every matched element.
2218                  * 
2219                  * @example $("input").value("test");
2220                  * @before <input type="text" value="some text"/>
2221                  * @result <input type="text" value="test"/>
2222                  *
2223                  * @name val
2224                  * @type jQuery
2225                  * @param String val Set the property to the specified value.
2226                  * @cat DOM/Attributes
2227                  */
2228                 val: "value",
2229                 
2230                 /**
2231                  * Get the html contents of the first matched element.
2232                  * 
2233                  * @example $("div").html();
2234                  * @before <div><input/></div>
2235                  * @result <input/>
2236                  *
2237                  * @name html
2238                  * @type String
2239                  * @cat DOM/Attributes
2240                  */
2241                  
2242                 /**
2243                  * Set the html contents of every matched element.
2244                  * 
2245                  * @example $("div").html("<b>new stuff</b>");
2246                  * @before <div><input/></div>
2247                  * @result <div><b>new stuff</b></div>
2248                  *
2249                  * @test var div = $("div");
2250                  * div.html("<b>test</b>");
2251                  * var pass = true;
2252                  * for ( var i = 0; i < div.size(); i++ ) {
2253                  *   if ( div.get(i).childNodes.length == 0 ) pass = false;
2254                  * }
2255                  * ok( pass, "Set HTML" );
2256                  *
2257                  * @name html
2258                  * @type jQuery
2259                  * @param String val Set the html contents to the specified value.
2260                  * @cat DOM/Attributes
2261                  */
2262                 html: "innerHTML",
2263                 
2264                 /**
2265                  * Get the current id of the first matched element.
2266                  * 
2267                  * @example $("input").id();
2268                  * @before <input type="text" id="test" value="some text"/>
2269                  * @result "test"
2270                  *
2271                  * @name id
2272                  * @type String
2273                  * @cat DOM/Attributes
2274                  */
2275                  
2276                 /**
2277                  * Set the id of every matched element.
2278                  * 
2279                  * @example $("input").id("newid");
2280                  * @before <input type="text" id="test" value="some text"/>
2281                  * @result <input type="text" id="newid" value="some text"/>
2282                  *
2283                  * @name id
2284                  * @type jQuery
2285                  * @param String val Set the property to the specified value.
2286                  * @cat DOM/Attributes
2287                  */
2288                 id: null,
2289                 
2290                 /**
2291                  * Get the current title of the first matched element.
2292                  * 
2293                  * @example $("img").title();
2294                  * @before <img src="test.jpg" title="my image"/>
2295                  * @result "my image"
2296                  *
2297                  * @name title
2298                  * @type String
2299                  * @cat DOM/Attributes
2300                  */
2301                  
2302                 /**
2303                  * Set the title of every matched element.
2304                  * 
2305                  * @example $("img").title("new title");
2306                  * @before <img src="test.jpg" title="my image"/>
2307                  * @result <img src="test.jpg" title="new image"/>
2308                  *
2309                  * @name title
2310                  * @type jQuery
2311                  * @param String val Set the property to the specified value.
2312                  * @cat DOM/Attributes
2313                  */
2314                 title: null,
2315                 
2316                 /**
2317                  * Get the current name of the first matched element.
2318                  * 
2319                  * @example $("input").name();
2320                  * @before <input type="text" name="username"/>
2321                  * @result "username"
2322                  *
2323                  * @name name
2324                  * @type String
2325                  * @cat DOM/Attributes
2326                  */
2327                  
2328                 /**
2329                  * Set the name of every matched element.
2330                  * 
2331                  * @example $("input").name("user");
2332                  * @before <input type="text" name="username"/>
2333                  * @result <input type="text" name="user"/>
2334                  *
2335                  * @name name
2336                  * @type jQuery
2337                  * @param String val Set the property to the specified value.
2338                  * @cat DOM/Attributes
2339                  */
2340                 name: null,
2341                 
2342                 /**
2343                  * Get the current href of the first matched element.
2344                  * 
2345                  * @example $("a").href();
2346                  * @before <a href="test.html">my link</a>
2347                  * @result "test.html"
2348                  *
2349                  * @name href
2350                  * @type String
2351                  * @cat DOM/Attributes
2352                  */
2353                  
2354                 /**
2355                  * Set the href of every matched element.
2356                  * 
2357                  * @example $("a").href("test2.html");
2358                  * @before <a href="test.html">my link</a>
2359                  * @result <a href="test2.html">my link</a>
2360                  *
2361                  * @name href
2362                  * @type jQuery
2363                  * @param String val Set the property to the specified value.
2364                  * @cat DOM/Attributes
2365                  */
2366                 href: null,
2367                 
2368                 /**
2369                  * Get the current src of the first matched element.
2370                  * 
2371                  * @example $("img").src();
2372                  * @before <img src="test.jpg" title="my image"/>
2373                  * @result "test.jpg"
2374                  *
2375                  * @name src
2376                  * @type String
2377                  * @cat DOM/Attributes
2378                  */
2379                  
2380                 /**
2381                  * Set the src of every matched element.
2382                  * 
2383                  * @example $("img").src("test2.jpg");
2384                  * @before <img src="test.jpg" title="my image"/>
2385                  * @result <img src="test2.jpg" title="my image"/>
2386                  *
2387                  * @name src
2388                  * @type jQuery
2389                  * @param String val Set the property to the specified value.
2390                  * @cat DOM/Attributes
2391                  */
2392                 src: null,
2393                 
2394                 /**
2395                  * Get the current rel of the first matched element.
2396                  * 
2397                  * @example $("a").rel();
2398                  * @before <a href="test.html" rel="nofollow">my link</a>
2399                  * @result "nofollow"
2400                  *
2401                  * @name rel
2402                  * @type String
2403                  * @cat DOM/Attributes
2404                  */
2405                  
2406                 /**
2407                  * Set the rel of every matched element.
2408                  * 
2409                  * @example $("a").rel("nofollow");
2410                  * @before <a href="test.html">my link</a>
2411                  * @result <a href="test.html" rel="nofollow">my link</a>
2412                  *
2413                  * @name rel
2414                  * @type jQuery
2415                  * @param String val Set the property to the specified value.
2416                  * @cat DOM/Attributes
2417                  */
2418                 rel: null
2419         },
2420         
2421         axis: {
2422                 /**
2423                  * Get a set of elements containing the unique parents of the matched
2424                  * set of elements.
2425                  *
2426                  * @example $("p").parent()
2427                  * @before <div><p>Hello</p><p>Hello</p></div>
2428                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2429                  *
2430                  * @name parent
2431                  * @type jQuery
2432                  * @cat DOM/Traversing
2433                  */
2434
2435                 /**
2436                  * Get a set of elements containing the unique parents of the matched
2437                  * set of elements, and filtered by an expression.
2438                  *
2439                  * @example $("p").parent(".selected")
2440                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2441                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2442                  *
2443                  * @name parent
2444                  * @type jQuery
2445                  * @param String expr An expression to filter the parents with
2446                  * @cat DOM/Traversing
2447                  */
2448                 parent: "a.parentNode",
2449
2450                 /**
2451                  * Get a set of elements containing the unique ancestors of the matched
2452                  * set of elements (except for the root element).
2453                  *
2454                  * @example $("span").ancestors()
2455                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2456                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2457                  *
2458                  * @name ancestors
2459                  * @type jQuery
2460                  * @cat DOM/Traversing
2461                  */
2462
2463                 /**
2464                  * Get a set of elements containing the unique ancestors of the matched
2465                  * set of elements, and filtered by an expression.
2466                  *
2467                  * @example $("span").ancestors("p")
2468                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2469                  * @result [ <p><span>Hello</span></p> ] 
2470                  *
2471                  * @name ancestors
2472                  * @type jQuery
2473                  * @param String expr An expression to filter the ancestors with
2474                  * @cat DOM/Traversing
2475                  */
2476                 ancestors: jQuery.parents,
2477                 
2478                 /**
2479                  * Get a set of elements containing the unique ancestors of the matched
2480                  * set of elements (except for the root element).
2481                  *
2482                  * @example $("span").ancestors()
2483                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2484                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2485                  *
2486                  * @name parents
2487                  * @type jQuery
2488                  * @cat DOM/Traversing
2489                  */
2490
2491                 /**
2492                  * Get a set of elements containing the unique ancestors of the matched
2493                  * set of elements, and filtered by an expression.
2494                  *
2495                  * @example $("span").ancestors("p")
2496                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2497                  * @result [ <p><span>Hello</span></p> ] 
2498                  *
2499                  * @name parents
2500                  * @type jQuery
2501                  * @param String expr An expression to filter the ancestors with
2502                  * @cat DOM/Traversing
2503                  */
2504                 parents: jQuery.parents,
2505
2506                 /**
2507                  * Get a set of elements containing the unique next siblings of each of the 
2508                  * matched set of elements.
2509                  * 
2510                  * It only returns the very next sibling, not all next siblings.
2511                  *
2512                  * @example $("p").next()
2513                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2514                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2515                  *
2516                  * @name next
2517                  * @type jQuery
2518                  * @cat DOM/Traversing
2519                  */
2520
2521                 /**
2522                  * Get a set of elements containing the unique next siblings of each of the 
2523                  * matched set of elements, and filtered by an expression.
2524                  * 
2525                  * It only returns the very next sibling, not all next siblings.
2526                  *
2527                  * @example $("p").next(".selected")
2528                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2529                  * @result [ <p class="selected">Hello Again</p> ]
2530                  *
2531                  * @name next
2532                  * @type jQuery
2533                  * @param String expr An expression to filter the next Elements with
2534                  * @cat DOM/Traversing
2535                  */
2536                 next: "jQuery.sibling(a).next",
2537
2538                 /**
2539                  * Get a set of elements containing the unique previous siblings of each of the 
2540                  * matched set of elements.
2541                  * 
2542                  * It only returns the immediately previous sibling, not all previous siblings.
2543                  *
2544                  * @example $("p").previous()
2545                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2546                  * @result [ <div><span>Hello Again</span></div> ]
2547                  *
2548                  * @name prev
2549                  * @type jQuery
2550                  * @cat DOM/Traversing
2551                  */
2552
2553                 /**
2554                  * Get a set of elements containing the unique previous siblings of each of the 
2555                  * matched set of elements, and filtered by an expression.
2556                  * 
2557                  * It only returns the immediately previous sibling, not all previous siblings.
2558                  *
2559                  * @example $("p").previous(".selected")
2560                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2561                  * @result [ <div><span>Hello</span></div> ]
2562                  *
2563                  * @name prev
2564                  * @type jQuery
2565                  * @param String expr An expression to filter the previous Elements with
2566                  * @cat DOM/Traversing
2567                  */
2568                 prev: "jQuery.sibling(a).prev",
2569
2570                 /**
2571                  * Get a set of elements containing all of the unique siblings of each of the 
2572                  * matched set of elements.
2573                  * 
2574                  * @example $("div").siblings()
2575                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2576                  * @result [ <p>Hello</p>, <p>And Again</p> ]
2577                  *
2578                  * @name siblings
2579                  * @type jQuery
2580                  * @cat DOM/Traversing
2581                  */
2582
2583                 /**
2584                  * Get a set of elements containing all of the unique siblings of each of the 
2585                  * matched set of elements, and filtered by an expression.
2586                  *
2587                  * @example $("div").siblings(".selected")
2588                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2589                  * @result [ <p class="selected">Hello Again</p> ]
2590                  *
2591                  * @name siblings
2592                  * @type jQuery
2593                  * @param String expr An expression to filter the sibling Elements with
2594                  * @cat DOM/Traversing
2595                  */
2596                 siblings: jQuery.sibling,
2597                 
2598                 
2599                 /**
2600                  * Get a set of elements containing all of the unique children of each of the 
2601                  * matched set of elements.
2602                  * 
2603                  * @example $("div").children()
2604                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2605                  * @result [ <span>Hello Again</span> ]
2606                  *
2607                  * @name children
2608                  * @type jQuery
2609                  * @cat DOM/Traversing
2610                  */
2611
2612                 /**
2613                  * Get a set of elements containing all of the unique children of each of the 
2614                  * matched set of elements, and filtered by an expression.
2615                  *
2616                  * @example $("div").children(".selected")
2617                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2618                  * @result [ <p class="selected">Hello Again</p> ]
2619                  *
2620                  * @name children
2621                  * @type jQuery
2622                  * @param String expr An expression to filter the child Elements with
2623                  * @cat DOM/Traversing
2624                  */
2625                 children: "jQuery.sibling(a.firstChild)"
2626         },
2627
2628         each: {
2629
2630                 removeAttr: function( key ) {
2631                         this.removeAttribute( key );
2632                 },
2633
2634                 /**
2635                  * Displays each of the set of matched elements if they are hidden.
2636                  * 
2637                  * @example $("p").show()
2638                  * @before <p style="display: none">Hello</p>
2639                  * @result [ <p style="display: block">Hello</p> ]
2640                  *
2641                  * @test var pass = true, div = $("div");
2642                  * div.show().each(function(){
2643                  *   if ( this.style.display == "none" ) pass = false;
2644                  * });
2645                  * ok( pass, "Show" );
2646                  *
2647                  * @name show
2648                  * @type jQuery
2649                  * @cat Effects
2650                  */
2651                 show: function(){
2652                         this.style.display = this.oldblock ? this.oldblock : "";
2653                         if ( jQuery.css(this,"display") == "none" )
2654                                 this.style.display = "block";
2655                 },
2656
2657                 /**
2658                  * Hides each of the set of matched elements if they are shown.
2659                  *
2660                  * @example $("p").hide()
2661                  * @before <p>Hello</p>
2662                  * @result [ <p style="display: none">Hello</p> ]
2663                  *
2664                  * var pass = true, div = $("div");
2665                  * div.hide().each(function(){
2666                  *   if ( this.style.display != "none" ) pass = false;
2667                  * });
2668                  * ok( pass, "Hide" );
2669                  *
2670                  * @name hide
2671                  * @type jQuery
2672                  * @cat Effects
2673                  */
2674                 hide: function(){
2675                         this.oldblock = this.oldblock || jQuery.css(this,"display");
2676                         if ( this.oldblock == "none" )
2677                                 this.oldblock = "block";
2678                         this.style.display = "none";
2679                 },
2680                 
2681                 /**
2682                  * Toggles each of the set of matched elements. If they are shown,
2683                  * toggle makes them hidden. If they are hidden, toggle
2684                  * makes them shown.
2685                  *
2686                  * @example $("p").toggle()
2687                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
2688                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2689                  *
2690                  * @name toggle
2691                  * @type jQuery
2692                  * @cat Effects
2693                  */
2694                 toggle: function(){
2695                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2696                 },
2697                 
2698                 /**
2699                  * Adds the specified class to each of the set of matched elements.
2700                  *
2701                  * @example $("p").addClass("selected")
2702                  * @before <p>Hello</p>
2703                  * @result [ <p class="selected">Hello</p> ]
2704                  *
2705                  * @test var div = $("div");
2706                  * div.addClass("test");
2707                  * var pass = true;
2708                  * for ( var i = 0; i < div.size(); i++ ) {
2709                  *  if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
2710                  * }
2711                  * ok( pass, "Add Class" );
2712                  * 
2713                  * @name addClass
2714                  * @type jQuery
2715                  * @param String class A CSS class to add to the elements
2716                  * @cat DOM
2717                  */
2718                 addClass: function(c){
2719                         jQuery.className.add(this,c);
2720                 },
2721                 
2722                 /**
2723                  * Removes the specified class from the set of matched elements.
2724                  *
2725                  * @example $("p").removeClass("selected")
2726                  * @before <p class="selected">Hello</p>
2727                  * @result [ <p>Hello</p> ]
2728                  *
2729                  * @test var div = $("div").addClass("test");
2730                  * div.removeClass("test");
2731                  * var pass = true;
2732                  * for ( var i = 0; i < div.size(); i++ ) {
2733                  *  if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
2734                  * }
2735                  * ok( pass, "Remove Class" );
2736                  *
2737                  * @name removeClass
2738                  * @type jQuery
2739                  * @param String class A CSS class to remove from the elements
2740                  * @cat DOM
2741                  */
2742                 removeClass: function(c){
2743                         jQuery.className.remove(this,c);
2744                 },
2745         
2746                 /**
2747                  * Adds the specified class if it is present, removes it if it is
2748                  * not present.
2749                  *
2750                  * @example $("p").toggleClass("selected")
2751                  * @before <p>Hello</p><p class="selected">Hello Again</p>
2752                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2753                  *
2754                  * @name toggleClass
2755                  * @type jQuery
2756                  * @param String class A CSS class with which to toggle the elements
2757                  * @cat DOM
2758                  */
2759                 toggleClass: function( c ){
2760                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
2761                 },
2762                 
2763                 /**
2764                  * Removes all matched elements from the DOM. This does NOT remove them from the
2765                  * jQuery object, allowing you to use the matched elements further.
2766                  *
2767                  * @example $("p").remove();
2768                  * @before <p>Hello</p> how are <p>you?</p>
2769                  * @result how are
2770                  *
2771                  * @name remove
2772                  * @type jQuery
2773                  * @cat DOM/Manipulation
2774                  */
2775                  
2776                 /**
2777                  * Removes only elements (out of the list of matched elements) that match
2778                  * the specified jQuery expression. This does NOT remove them from the
2779                  * jQuery object, allowing you to use the matched elements further.
2780                  *
2781                  * @example $("p").remove(".hello");
2782                  * @before <p class="hello">Hello</p> how are <p>you?</p>
2783                  * @result how are <p>you?</p>
2784                  *
2785                  * @name remove
2786                  * @type jQuery
2787                  * @param String expr A jQuery expression to filter elements by.
2788                  * @cat DOM/Manipulation
2789                  */
2790                 remove: function(a){
2791                         if ( !a || jQuery.filter( a, [this] ).r )
2792                                 this.parentNode.removeChild( this );
2793                 },
2794         
2795                 /**
2796                  * Removes all child nodes from the set of matched elements.
2797                  *
2798                  * @example $("p").empty()
2799                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2800                  * @result [ <p></p> ]
2801                  *
2802                  * @name empty
2803                  * @type jQuery
2804                  * @cat DOM/Manipulation
2805                  */
2806                 empty: function(){
2807                         while ( this.firstChild )
2808                                 this.removeChild( this.firstChild );
2809                 },
2810                 
2811                 /**
2812                  * Binds a particular event (like click) to a each of a set of match elements.
2813                  *
2814                  * @example $("p").bind( "click", function() { alert("Hello"); } )
2815                  * @before <p>Hello</p>
2816                  * @result [ <p>Hello</p> ]
2817                  *
2818                  * Cancel a default action and prevent it from bubbling by returning false
2819                  * from your function.
2820                  *
2821                  * @example $("form").bind( "submit", function() { return false; } )
2822                  *
2823                  * Cancel a default action by using the preventDefault method.
2824                  *
2825                  * @example $("form").bind( "submit", function() { e.preventDefault(); } )
2826                  *
2827                  * Stop an event from bubbling by using the stopPropogation method.
2828                  *
2829                  * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
2830                  *
2831                  * @name bind
2832                  * @type jQuery
2833                  * @param String type An event type
2834                  * @param Function fn A function to bind to the event on each of the set of matched elements
2835                  * @cat Events
2836                  */
2837                 bind: function( type, fn ) {
2838                         if ( fn.constructor == String )
2839                                 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
2840                         jQuery.event.add( this, type, fn );
2841                 },
2842                 
2843                 /**
2844                  * The opposite of bind, removes a bound event from each of the matched
2845                  * elements. You must pass the identical function that was used in the original 
2846                  * bind method.
2847                  *
2848                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
2849                  * @before <p onclick="alert('Hello');">Hello</p>
2850                  * @result [ <p>Hello</p> ]
2851                  *
2852                  * @name unbind
2853                  * @type jQuery
2854                  * @param String type An event type
2855                  * @param Function fn A function to unbind from the event on each of the set of matched elements
2856                  * @cat Events
2857                  */
2858                  
2859                 /**
2860                  * Removes all bound events of a particular type from each of the matched
2861                  * elements.
2862                  *
2863                  * @example $("p").unbind( "click" )
2864                  * @before <p onclick="alert('Hello');">Hello</p>
2865                  * @result [ <p>Hello</p> ]
2866                  *
2867                  * @name unbind
2868                  * @type jQuery
2869                  * @param String type An event type
2870                  * @cat Events
2871                  */
2872                  
2873                 /**
2874                  * Removes all bound events from each of the matched elements.
2875                  *
2876                  * @example $("p").unbind()
2877                  * @before <p onclick="alert('Hello');">Hello</p>
2878                  * @result [ <p>Hello</p> ]
2879                  *
2880                  * @name unbind
2881                  * @type jQuery
2882                  * @cat Events
2883                  */
2884                 unbind: function( type, fn ) {
2885                         jQuery.event.remove( this, type, fn );
2886                 },
2887                 
2888                 /**
2889                  * Trigger a type of event on every matched element.
2890                  *
2891                  * @example $("p").trigger("click")
2892                  * @before <p click="alert('hello')">Hello</p>
2893                  * @result alert('hello')
2894                  *
2895                  * @name trigger
2896                  * @type jQuery
2897                  * @param String type An event type to trigger.
2898                  * @cat Events
2899                  */
2900                 trigger: function( type, data ) {
2901                         jQuery.event.trigger( type, data, this );
2902                 }
2903         }
2904 };
2905
2906 jQuery.init();