2 * jQuery @VERSION - New Wave Javascript
4 * Copyright (c) 2006 John Resig (jquery.com)
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
6 * and GPL (GPL-LICENSE.txt) licenses.
12 // Global undefined variable
13 window.undefined = window.undefined;
16 * Create a new jQuery Object
23 var jQuery = function(a,c) {
25 // Shortcut for document ready (because $(document).each() is silly)
26 if ( a && typeof a == "function" && jQuery.fn.ready && !a.nodeType && a[0] == undefined ) // Safari reports typeof on DOM NodeLists as a function
27 return jQuery(document).ready(a);
29 // Make sure that a selection was provided
30 a = a || jQuery.context || document;
32 // Watch for when a jQuery object is passed as the selector
34 return jQuery( jQuery.merge( a, [] ) );
36 // Watch for when a jQuery object is passed at the context
38 return jQuery( c ).find(a);
40 // If the context is global, return a new object
42 return new jQuery(a,c);
44 // Handle HTML strings
45 if ( a.constructor == String ) {
46 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
47 if ( m ) a = jQuery.clean( [ m[1] ] );
50 // Watch for when an array is passed in
51 this.get( a.constructor == Array || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType ?
52 // Assume that it is an array of DOM Elements
53 jQuery.merge( a, [] ) :
55 // Find the matching elements and save them for later
56 jQuery.find( a, c ) );
58 // See if an extra function was provided
59 var fn = arguments[ arguments.length - 1 ];
61 // If so, execute it in context
62 if ( fn && typeof fn == "function" )
68 // Map over the $ in case of overwrite
69 if ( typeof $ != "undefined" )
73 * This function accepts a string containing a CSS selector,
74 * basic XPath, or raw HTML, which is then used to match a set of elements.
75 * The HTML string is different from the traditional selectors in that
76 * it creates the DOM elements representing that HTML string, on the fly,
77 * to be (assumedly) inserted into the document later.
79 * The core functionality of jQuery centers around this function.
80 * Everything in jQuery is based upon this, or uses this in some way.
81 * The most basic use of this function is to pass in an expression
82 * (usually consisting of CSS or XPath), which then finds all matching
83 * elements and remembers them for later use.
85 * By default, $() looks for DOM elements within the context of the
86 * current HTML document.
88 * @example $("div > p")
89 * @desc This finds all p elements that are children of a div element.
90 * @before <p>one</p> <div><p>two</p></div> <p>three</p>
91 * @result [ <p>two</p> ]
93 * @example $("<div><p>Hello</p></div>").appendTo("#body")
94 * @desc Creates a div element (and all of its contents) dynamically,
95 * and appends it to the element with the ID of body. Internally, an
96 * element is created and it's innerHTML property set to the given markup.
97 * It is therefore both quite flexible and limited.
100 * @param String expr An expression to search with, or a string of HTML to create on the fly.
106 * This function accepts a string containing a CSS selector, or
107 * basic XPath, which is then used to match a set of elements with the
108 * context of the specified DOM element, or document
110 * @example $("div", xml.responseXML)
111 * @desc This finds all div elements within the specified XML document.
114 * @param String expr An expression to search with.
115 * @param Element context A DOM Element, or Document, representing the base context.
121 * Wrap jQuery functionality around a specific DOM Element.
122 * This function also accepts XML Documents and Window objects
123 * as valid arguments (even though they are not DOM Elements).
125 * @example $(document).find("div > p")
126 * @before <p>one</p> <div><p>two</p></div> <p>three</p>
127 * @result [ <p>two</p> ]
129 * @example $(document.body).background( "black" );
130 * @desc Sets the background color of the page to black.
133 * @param Element elem A DOM element to be encapsulated by a jQuery object.
139 * Wrap jQuery functionality around a set of DOM Elements.
141 * @example $( myForm.elements ).hide()
142 * @desc Hides all the input elements within a form
145 * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
151 * A shorthand for $(document).ready(), allowing you to bind a function
152 * to be executed when the DOM document has finished loading. This function
153 * behaves just like $(document).ready(), in that it should be used to wrap
154 * all of the other $() operations on your page. While this function is,
155 * technically, chainable - there really isn't much use for chaining against it.
156 * You can have as many $(document).ready events on your page as you like.
158 * @example $(function(){
159 * // Document is ready
161 * @desc Executes the function when the DOM is ready to be used.
164 * @param Function fn The function to execute when the DOM is ready.
170 * A means of creating a cloned copy of a jQuery object. This function
171 * copies the set of matched elements from one jQuery object and creates
172 * another, new, jQuery object containing the same elements.
174 * @example var div = $("div");
175 * $( div ).find("p");
176 * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).
179 * @param jQuery obj The jQuery object to be cloned.
184 // Map the jQuery namespace to the '$' one
187 jQuery.fn = jQuery.prototype = {
189 * The current version of jQuery.
200 * The number of elements currently matched.
202 * @example $("img").length;
203 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
213 * The number of elements currently matched.
215 * @example $("img").size();
216 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
228 * Access all matched elements. This serves as a backwards-compatible
229 * way of accessing all matched elements (other than the jQuery object
230 * itself, which is, in fact, an array of elements).
232 * @example $("img").get();
233 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
234 * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
237 * @type Array<Element>
242 * Access a single matched element. num is used to access the
243 * Nth element matched.
245 * @example $("img").get(1);
246 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
247 * @result [ <img src="test1.jpg"/> ]
251 * @param Number num Access the element in the Nth position.
256 * Set the jQuery object to an array of elements.
258 * @example $("img").get([ document.body ]);
259 * @result $("img").get() == [ document.body ]
264 * @param Elements elems An array of elements
267 get: function( num ) {
268 // Watch for when an array (of elements) is passed in
269 if ( num && num.constructor == Array ) {
271 // Use a tricky hack to make the jQuery object
272 // look and feel like an array
274 [].push.apply( this, num );
278 return num == undefined ?
280 // Return a 'clean' array
281 jQuery.merge( this, [] ) :
283 // Return just the object
288 * Execute a function within the context of every matched element.
289 * This means that every time the passed-in function is executed
290 * (which is once for every element matched) the 'this' keyword
291 * points to the specific element.
293 * Additionally, the function, when executed, is passed a single
294 * argument representing the position of the element in the matched
297 * @example $("img").each(function(){
298 * this.src = "test.jpg";
300 * @before <img/> <img/>
301 * @result <img src="test.jpg"/> <img src="test.jpg"/>
303 * @example $("img").each(function(i){
304 * alert( "Image #" + i + " is " + this );
306 * @before <img/> <img/>
307 * @result <img src="test.jpg"/> <img src="test.jpg"/>
311 * @param Function fn A function to execute
314 each: function( fn, args ) {
315 return jQuery.each( this, fn, args );
319 * Searches every matched element for the object and returns
320 * the index of the element, if found, starting with zero.
321 * Returns -1 if the object wasn't found.
323 * @example $("*").index(document.getElementById('foobar'))
324 * @before <div id="foobar"></div><b></b><span id="foo"></span>
327 * @example $("*").index(document.getElementById('foo'))
328 * @before <div id="foobar"></div><b></b><span id="foo"></span>
331 * @example $("*").index(document.getElementById('bar'))
332 * @before <div id="foobar"></div><b></b><span id="foo"></span>
337 * @param Object obj Object to search for
340 index: function( obj ) {
342 this.each(function(i){
343 if ( this == obj ) pos = i;
349 * Access a property on the first matched element.
350 * This method makes it easy to retrieve a property value
351 * from the first matched element.
353 * @example $("img").attr("src");
354 * @before <img src="test.jpg"/>
359 * @param String name The name of the property to access.
364 * Set a hash of key/value object properties to all matched elements.
365 * This serves as the best way to set a large number of properties
366 * on all matched elements.
368 * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
370 * @result <img src="test.jpg" alt="Test Image"/>
374 * @param Hash prop A set of key/value pairs to set as object properties.
379 * Set a single property to a value, on all matched elements.
381 * @example $("img").attr("src","test.jpg");
383 * @result <img src="test.jpg"/>
387 * @param String key The name of the property to set.
388 * @param Object value The value to set the property to.
391 attr: function( key, value, type ) {
392 // Check to see if we're setting style values
393 return key.constructor != String || value != undefined ?
394 this.each(function(){
395 // See if we're setting a hash of styles
396 if ( value == undefined )
397 // Set all the styles
398 for ( var prop in key )
400 type ? this.style : this,
404 // See if we're setting a single key/value style
407 type ? this.style : this,
412 // Look for the case where we're accessing a style value
413 jQuery[ type || "attr" ]( this[0], key );
417 * Access a style property on the first matched element.
418 * This method makes it easy to retrieve a style property value
419 * from the first matched element.
421 * @example $("p").css("color");
422 * @before <p style="color:red;">Test Paragraph.</p>
424 * @desc Retrieves the color style of the first paragraph
426 * @example $("p").css("fontWeight");
427 * @before <p style="font-weight: bold;">Test Paragraph.</p>
429 * @desc Retrieves the font-weight style of the first paragraph.
430 * Note that for all style properties with a dash (like 'font-weight'), you have to
431 * write it in camelCase. In other words: Every time you have a '-' in a
432 * property, remove it and replace the next character with an uppercase
433 * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
434 * borderStyle, borderBottomWidth etc.
438 * @param String name The name of the property to access.
443 * Set a hash of key/value style properties to all matched elements.
444 * This serves as the best way to set a large number of style properties
445 * on all matched elements.
447 * @example $("p").css({ color: "red", background: "blue" });
448 * @before <p>Test Paragraph.</p>
449 * @result <p style="color:red; background:blue;">Test Paragraph.</p>
453 * @param Hash prop A set of key/value pairs to set as style properties.
458 * Set a single style property to a value, on all matched elements.
460 * @example $("p").css("color","red");
461 * @before <p>Test Paragraph.</p>
462 * @result <p style="color:red;">Test Paragraph.</p>
463 * @desc Changes the color of all paragraphs to red
467 * @param String key The name of the property to set.
468 * @param Object value The value to set the property to.
471 css: function( key, value ) {
472 return this.attr( key, value, "curCSS" );
476 * Retrieve the text contents of all matched elements. The result is
477 * a string that contains the combined text contents of all matched
478 * elements. This method works on both HTML and XML documents.
480 * @example $("p").text();
481 * @before <p>Test Paragraph.</p>
482 * @result Test Paragraph.
491 for ( var j = 0; j < e.length; j++ ) {
492 var r = e[j].childNodes;
493 for ( var i = 0; i < r.length; i++ )
494 if ( r[i].nodeType != 8 )
495 t += r[i].nodeType != 1 ?
496 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
502 * Wrap all matched elements with a structure of other elements.
503 * This wrapping process is most useful for injecting additional
504 * stucture into a document, without ruining the original semantic
505 * qualities of a document.
507 * This works by going through the first element
508 * provided (which is generated, on the fly, from the provided HTML)
509 * and finds the deepest ancestor element within its
510 * structure - it is that element that will en-wrap everything else.
512 * This does not work with elements that contain text. Any necessary text
513 * must be added after the wrapping is done.
515 * @example $("p").wrap("<div class='wrap'></div>");
516 * @before <p>Test Paragraph.</p>
517 * @result <div class='wrap'><p>Test Paragraph.</p></div>
521 * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
522 * @cat DOM/Manipulation
526 * Wrap all matched elements with a structure of other elements.
527 * This wrapping process is most useful for injecting additional
528 * stucture into a document, without ruining the original semantic
529 * qualities of a document.
531 * This works by going through the first element
532 * provided and finding the deepest ancestor element within its
533 * structure - it is that element that will en-wrap everything else.
535 * This does not work with elements that contain text. Any necessary text
536 * must be added after the wrapping is done.
538 * @example $("p").wrap( document.getElementById('content') );
539 * @before <p>Test Paragraph.</p><div id="content"></div>
540 * @result <div id="content"><p>Test Paragraph.</p></div>
544 * @param Element elem A DOM element that will be wrapped.
545 * @cat DOM/Manipulation
548 // The elements to wrap the target around
549 var a = jQuery.clean(arguments);
551 // Wrap each of the matched elements individually
552 return this.each(function(){
553 // Clone the structure that we're using to wrap
554 var b = a[0].cloneNode(true);
556 // Insert it before the element to be wrapped
557 this.parentNode.insertBefore( b, this );
559 // Find the deepest point in the wrap structure
560 while ( b.firstChild )
563 // Move the matched element to within the wrap structure
564 b.appendChild( this );
569 * Append any number of elements to the inside of every matched elements,
570 * generated from the provided HTML.
571 * This operation is similar to doing an appendChild to all the
572 * specified elements, adding them into the document.
574 * @example $("p").append("<b>Hello</b>");
575 * @before <p>I would like to say: </p>
576 * @result <p>I would like to say: <b>Hello</b></p>
580 * @param String html A string of HTML, that will be created on the fly and appended to the target.
581 * @cat DOM/Manipulation
585 * Append an element to the inside of all matched elements.
586 * This operation is similar to doing an appendChild to all the
587 * specified elements, adding them into the document.
589 * @example $("p").append( $("#foo")[0] );
590 * @before <p>I would like to say: </p><b id="foo">Hello</b>
591 * @result <p>I would like to say: <b id="foo">Hello</b></p>
595 * @param Element elem A DOM element that will be appended.
596 * @cat DOM/Manipulation
600 * Append any number of elements to the inside of all matched elements.
601 * This operation is similar to doing an appendChild to all the
602 * specified elements, adding them into the document.
604 * @example $("p").append( $("b") );
605 * @before <p>I would like to say: </p><b>Hello</b>
606 * @result <p>I would like to say: <b>Hello</b></p>
610 * @param Array<Element> elems An array of elements, all of which will be appended.
611 * @cat DOM/Manipulation
614 return this.domManip(arguments, true, 1, function(a){
615 this.appendChild( a );
620 * Prepend any number of elements to the inside of every matched elements,
621 * generated from the provided HTML.
622 * This operation is the best way to insert dynamically created elements
623 * inside, at the beginning, of all the matched element.
625 * @example $("p").prepend("<b>Hello</b>");
626 * @before <p>I would like to say: </p>
627 * @result <p><b>Hello</b>I would like to say: </p>
631 * @param String html A string of HTML, that will be created on the fly and appended to the target.
632 * @cat DOM/Manipulation
636 * Prepend an element to the inside of all matched elements.
637 * This operation is the best way to insert an element inside, at the
638 * beginning, of all the matched element.
640 * @example $("p").prepend( $("#foo")[0] );
641 * @before <p>I would like to say: </p><b id="foo">Hello</b>
642 * @result <p><b id="foo">Hello</b>I would like to say: </p>
646 * @param Element elem A DOM element that will be appended.
647 * @cat DOM/Manipulation
651 * Prepend any number of elements to the inside of all matched elements.
652 * This operation is the best way to insert a set of elements inside, at the
653 * beginning, of all the matched element.
655 * @example $("p").prepend( $("b") );
656 * @before <p>I would like to say: </p><b>Hello</b>
657 * @result <p><b>Hello</b>I would like to say: </p>
661 * @param Array<Element> elems An array of elements, all of which will be appended.
662 * @cat DOM/Manipulation
664 prepend: function() {
665 return this.domManip(arguments, true, -1, function(a){
666 this.insertBefore( a, this.firstChild );
671 * Insert any number of dynamically generated elements before each of the
674 * @example $("p").before("<b>Hello</b>");
675 * @before <p>I would like to say: </p>
676 * @result <b>Hello</b><p>I would like to say: </p>
680 * @param String html A string of HTML, that will be created on the fly and appended to the target.
681 * @cat DOM/Manipulation
685 * Insert an element before each of the matched elements.
687 * @example $("p").before( $("#foo")[0] );
688 * @before <p>I would like to say: </p><b id="foo">Hello</b>
689 * @result <b id="foo">Hello</b><p>I would like to say: </p>
693 * @param Element elem A DOM element that will be appended.
694 * @cat DOM/Manipulation
698 * Insert any number of elements before each of the matched elements.
700 * @example $("p").before( $("b") );
701 * @before <p>I would like to say: </p><b>Hello</b>
702 * @result <b>Hello</b><p>I would like to say: </p>
706 * @param Array<Element> elems An array of elements, all of which will be appended.
707 * @cat DOM/Manipulation
710 return this.domManip(arguments, false, 1, function(a){
711 this.parentNode.insertBefore( a, this );
716 * Insert any number of dynamically generated elements after each of the
719 * @example $("p").after("<b>Hello</b>");
720 * @before <p>I would like to say: </p>
721 * @result <p>I would like to say: </p><b>Hello</b>
725 * @param String html A string of HTML, that will be created on the fly and appended to the target.
726 * @cat DOM/Manipulation
730 * Insert an element after each of the matched elements.
732 * @example $("p").after( $("#foo")[0] );
733 * @before <b id="foo">Hello</b><p>I would like to say: </p>
734 * @result <p>I would like to say: </p><b id="foo">Hello</b>
738 * @param Element elem A DOM element that will be appended.
739 * @cat DOM/Manipulation
743 * Insert any number of elements after each of the matched elements.
745 * @example $("p").after( $("b") );
746 * @before <b>Hello</b><p>I would like to say: </p>
747 * @result <p>I would like to say: </p><b>Hello</b>
751 * @param Array<Element> elems An array of elements, all of which will be appended.
752 * @cat DOM/Manipulation
755 return this.domManip(arguments, false, -1, function(a){
756 this.parentNode.insertBefore( a, this.nextSibling );
761 * End the most recent 'destructive' operation, reverting the list of matched elements
762 * back to its previous state. After an end operation, the list of matched elements will
763 * revert to the last state of matched elements.
765 * @example $("p").find("span").end();
766 * @before <p><span>Hello</span>, how are you?</p>
767 * @result $("p").find("span").end() == [ <p>...</p> ]
771 * @cat DOM/Traversing
774 if( !(this.stack && this.stack.length) )
776 return this.get( this.stack.pop() );
780 * Searches for all elements that match the specified expression.
781 * This method is the optimal way of finding additional descendant
782 * elements with which to process.
784 * All searching is done using a jQuery expression. The expression can be
785 * written using CSS 1-3 Selector syntax, or basic XPath.
787 * @example $("p").find("span");
788 * @before <p><span>Hello</span>, how are you?</p>
789 * @result $("p").find("span") == [ <span>Hello</span> ]
793 * @param String expr An expression to search with.
794 * @cat DOM/Traversing
797 return this.pushStack( jQuery.map( this, function(a){
798 return jQuery.find(t,a);
803 * Create cloned copies of all matched DOM Elements. This does
804 * not create a cloned copy of this particular jQuery object,
805 * instead it creates duplicate copies of all DOM Elements.
806 * This is useful for moving copies of the elements to another
807 * location in the DOM.
809 * @example $("b").clone().prependTo("p");
810 * @before <b>Hello</b><p>, how are you?</p>
811 * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
815 * @cat DOM/Manipulation
817 clone: function(deep) {
818 return this.pushStack( jQuery.map( this, function(a){
819 return a.cloneNode( deep != undefined ? deep : true );
824 * Removes all elements from the set of matched elements that do not
825 * match the specified expression. This method is used to narrow down
826 * the results of a search.
828 * All searching is done using a jQuery expression. The expression
829 * can be written using CSS 1-3 Selector syntax, or basic XPath.
831 * @example $("p").filter(".selected")
832 * @before <p class="selected">Hello</p><p>How are you?</p>
833 * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
837 * @param String expr An expression to search with.
838 * @cat DOM/Traversing
842 * Removes all elements from the set of matched elements that do not
843 * match at least one of the expressions passed to the function. This
844 * method is used when you want to filter the set of matched elements
845 * through more than one expression.
847 * Elements will be retained in the jQuery object if they match at
848 * least one of the expressions passed.
850 * @example $("p").filter([".selected", ":first"])
851 * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
852 * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
856 * @param Array<String> exprs A set of expressions to evaluate against
857 * @cat DOM/Traversing
859 filter: function(t) {
860 return this.pushStack(
861 t.constructor == Array &&
862 jQuery.map(this,function(a){
863 for ( var i = 0; i < t.length; i++ )
864 if ( jQuery.filter(t[i],[a]).r.length )
869 t.constructor == Boolean &&
870 ( t ? this.get() : [] ) ||
872 typeof t == "function" &&
873 jQuery.grep( this, t ) ||
875 jQuery.filter(t,this).r, arguments );
879 * Removes the specified Element from the set of matched elements. This
880 * method is used to remove a single Element from a jQuery object.
882 * @example $("p").not( document.getElementById("selected") )
883 * @before <p>Hello</p><p id="selected">Hello Again</p>
884 * @result [ <p>Hello</p> ]
888 * @param Element el An element to remove from the set
889 * @cat DOM/Traversing
893 * Removes elements matching the specified expression from the set
894 * of matched elements. This method is used to remove one or more
895 * elements from a jQuery object.
897 * @example $("p").not("#selected")
898 * @before <p>Hello</p><p id="selected">Hello Again</p>
899 * @result [ <p>Hello</p> ]
903 * @param String expr An expression with which to remove matching elements
904 * @cat DOM/Traversing
907 return this.pushStack( t.constructor == String ?
908 jQuery.filter(t,this,false).r :
909 jQuery.grep(this,function(a){ return a != t; }), arguments );
913 * Adds the elements matched by the expression to the jQuery object. This
914 * can be used to concatenate the result sets of two expressions.
916 * @example $("p").add("span")
917 * @before <p>Hello</p><p><span>Hello Again</span></p>
918 * @result [ <p>Hello</p>, <span>Hello Again</span> ]
922 * @param String expr An expression whose matched elements are added
923 * @cat DOM/Traversing
927 * Adds each of the Elements in the array to the set of matched elements.
928 * This is used to add a set of Elements to a jQuery object.
930 * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
931 * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
932 * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
936 * @param Array<Element> els An array of Elements to add
937 * @cat DOM/Traversing
941 * Adds a single Element to the set of matched elements. This is used to
942 * add a single Element to a jQuery object.
944 * @example $("p").add( document.getElementById("a") )
945 * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
946 * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
950 * @param Element el An Element to add
951 * @cat DOM/Traversing
954 return this.pushStack( jQuery.merge( this, t.constructor == String ?
955 jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
959 * Checks the current selection against an expression and returns true,
960 * if the selection fits the given expression. Does return false, if the
961 * selection does not fit or the expression is not valid.
963 * @example $("input[@type='checkbox']").parent().is("form")
964 * @before <form><input type="checkbox" /></form>
966 * @desc Returns true, because the parent of the input is a form element
968 * @example $("input[@type='checkbox']").parent().is("form")
969 * @before <form><p><input type="checkbox" /></p></form>
971 * @desc Returns false, because the parent of the input is a p element
973 * @example $("form").is(null)
974 * @before <form></form>
976 * @desc An invalid expression always returns false.
980 * @param String expr The expression with which to filter
981 * @cat DOM/Traversing
984 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
993 * @param Boolean table
995 * @param Function fn The function doing the DOM manipulation.
999 domManip: function(args, table, dir, fn){
1000 var clone = this.size() > 1;
1001 var a = jQuery.clean(args);
1003 return this.each(function(){
1006 if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() != "THEAD" ) {
1007 var tbody = this.getElementsByTagName("tbody");
1009 if ( !tbody.length ) {
1010 obj = document.createElement("tbody");
1011 this.appendChild( obj );
1016 for ( var i = ( dir < 0 ? a.length - 1 : 0 );
1017 i != ( dir < 0 ? dir : a.length ); i += dir ) {
1018 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1033 pushStack: function(a,args) {
1034 var fn = args && args[args.length-1];
1035 var fn2 = args && args[args.length-2];
1037 if ( fn && fn.constructor != Function ) fn = null;
1038 if ( fn2 && fn2.constructor != Function ) fn2 = null;
1041 if ( !this.stack ) this.stack = [];
1042 this.stack.push( this.get() );
1045 var old = this.get();
1048 if ( fn2 && a.length || !fn2 )
1049 this.each( fn2 || fn ).get( old );
1051 this.get( old ).each( fn );
1059 * Extends the jQuery object itself. Can be used to add both static
1060 * functions and plugin methods.
1062 * @example $.fn.extend({
1063 * check: function() {
1064 * this.each(function() { this.checked = true; });
1066 * uncheck: function() {
1067 * this.each(function() { this.checked = false; });
1070 * $("input[@type=checkbox]").check();
1071 * $("input[@type=radio]").uncheck();
1072 * @desc Adds two plugin methods.
1082 * Extend one object with another, returning the original,
1083 * modified, object. This is a great utility for simple inheritance.
1085 * @example var settings = { validate: false, limit: 5, name: "foo" };
1086 * var options = { validate: true, name: "bar" };
1087 * jQuery.extend(settings, options);
1088 * @result settings == { validate: true, limit: 5, name: "bar" }
1091 * @param Object obj The object to extend
1092 * @param Object prop The object that will be merged into the first.
1096 jQuery.extend = jQuery.fn.extend = function(obj,prop) {
1097 // Watch for the case where null or undefined gets passed in by accident
1098 if ( arguments.length > 1 && (prop === null || prop == undefined) )
1101 // If no property object was provided, then we're extending jQuery
1102 if ( !prop ) { prop = obj; obj = this; }
1104 // Extend the base object
1105 for ( var i in prop ) obj[i] = prop[i];
1107 // Return the modified object
1119 jQuery.initDone = true;
1121 jQuery.each( jQuery.macros.axis, function(i,n){
1122 jQuery.fn[ i ] = function(a) {
1123 var ret = jQuery.map(this,n);
1124 if ( a && a.constructor == String )
1125 ret = jQuery.filter(a,ret).r;
1126 return this.pushStack( ret, arguments );
1130 jQuery.each( jQuery.macros.to, function(i,n){
1131 jQuery.fn[ i ] = function(){
1133 return this.each(function(){
1134 for ( var j = 0; j < a.length; j++ )
1135 jQuery(a[j])[n]( this );
1140 jQuery.each( jQuery.macros.each, function(i,n){
1141 jQuery.fn[ i ] = function() {
1142 return this.each( n, arguments );
1146 jQuery.each( jQuery.macros.filter, function(i,n){
1147 jQuery.fn[ n ] = function(num,fn) {
1148 return this.filter( ":" + n + "(" + num + ")", fn );
1152 jQuery.each( jQuery.macros.attr, function(i,n){
1154 jQuery.fn[ i ] = function(h) {
1155 return h == undefined ?
1156 this.length ? this[0][n] : null :
1161 jQuery.each( jQuery.macros.css, function(i,n){
1162 jQuery.fn[ n ] = function(h) {
1163 return h == undefined ?
1164 ( this.length ? jQuery.css( this[0], n ) : null ) :
1172 * A generic iterator function, which can be used to seemlessly
1173 * iterate over both objects and arrays. This function is not the same
1174 * as $().each() - which is used to iterate, exclusively, over a jQuery
1175 * object. This function can be used to iterate over anything.
1177 * @example $.each( [0,1,2], function(i){
1178 * alert( "Item #" + i + ": " + this );
1180 * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
1182 * @example $.each( { name: "John", lang: "JS" }, function(i){
1183 * alert( "Name: " + i + ", Value: " + this );
1185 * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
1188 * @param Object obj The object, or array, to iterate over.
1189 * @param Function fn The function that will be executed on every object.
1193 each: function( obj, fn, args ) {
1194 if ( obj.length == undefined )
1195 for ( var i in obj )
1196 fn.apply( obj[i], args || [i, obj[i]] );
1198 for ( var i = 0; i < obj.length; i++ )
1199 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1205 if (jQuery.className.has(o,c)) return;
1206 o.className += ( o.className ? " " : "" ) + c;
1208 remove: function(o,c){
1212 var classes = o.className.split(" ");
1213 for(var i=0; i<classes.length; i++) {
1214 if(classes[i] == c) {
1215 classes.splice(i, 1);
1219 o.className = classes.join(' ');
1222 has: function(e,a) {
1223 if ( e.className != undefined )
1225 return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
1230 * Swap in/out style options.
1233 swap: function(e,o,f) {
1234 for ( var i in o ) {
1235 e.style["old"+i] = e.style[i];
1240 e.style[i] = e.style["old"+i];
1243 css: function(e,p) {
1244 if ( p == "height" || p == "width" ) {
1245 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1247 for ( var i=0; i<d.length; i++ ) {
1248 old["padding" + d[i]] = 0;
1249 old["border" + d[i] + "Width"] = 0;
1252 jQuery.swap( e, old, function() {
1253 if (jQuery.css(e,"display") != "none") {
1254 oHeight = e.offsetHeight;
1255 oWidth = e.offsetWidth;
1257 e = jQuery(e.cloneNode(true))
1258 .find(":radio").removeAttr("checked").end()
1260 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1261 }).appendTo(e.parentNode)[0];
1263 var parPos = jQuery.css(e.parentNode,"position");
1264 if ( parPos == "" || parPos == "static" )
1265 e.parentNode.style.position = "relative";
1267 oHeight = e.clientHeight;
1268 oWidth = e.clientWidth;
1270 if ( parPos == "" || parPos == "static" )
1271 e.parentNode.style.position = "static";
1273 e.parentNode.removeChild(e);
1277 return p == "height" ? oHeight : oWidth;
1280 return jQuery.curCSS( e, p );
1283 curCSS: function(elem, prop, force) {
1286 if (prop == 'opacity' && jQuery.browser.msie)
1287 return jQuery.attr(elem.style, 'opacity');
1289 if (prop == "float" || prop == "cssFloat")
1290 prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1292 if (!force && elem.style[prop]) {
1294 ret = elem.style[prop];
1296 } else if (elem.currentStyle) {
1298 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1299 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1301 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1303 if (prop == "cssFloat" || prop == "styleFloat")
1306 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1307 var cur = document.defaultView.getComputedStyle(elem, null);
1310 ret = cur.getPropertyValue(prop);
1311 else if ( prop == 'display' )
1314 jQuery.swap(elem, { display: 'block' }, function() {
1315 ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1323 clean: function(a) {
1325 for ( var i = 0; i < a.length; i++ ) {
1327 if ( arg.constructor == String ) { // Convert html string into DOM nodes
1328 // Trim whitespace, otherwise indexOf won't work as expected
1329 var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""];
1331 if ( !s.indexOf("<opt") ) // option or optgroup
1332 wrap = [1, "<select>", "</select>"];
1333 else if ( !s.indexOf("<thead") || !s.indexOf("<tbody") )
1334 wrap = [1, "<table>", "</table>"];
1335 else if ( !s.indexOf("<tr") )
1336 wrap = [2, "<table>", "</table>"]; // tbody auto-inserted
1337 else if ( !s.indexOf("<td") || !s.indexOf("<th") )
1338 wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
1340 // Go to html and back, then peel off extra wrappers
1341 div.innerHTML = wrap[1] + s + wrap[2];
1342 while ( wrap[0]-- ) div = div.firstChild;
1343 arg = div.childNodes;
1347 if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
1348 for ( var n = 0; n < arg.length; n++ ) // Handles Array, jQuery, DOM NodeList collections
1351 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
1358 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1359 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1367 last: "i==r.length-1",
1372 "nth-child": "jQuery.sibling(a,m[3]).cur",
1373 "first-child": "jQuery.sibling(a,0).cur",
1374 "last-child": "jQuery.sibling(a,0).last",
1375 "only-child": "jQuery.sibling(a).length==1",
1378 parent: "a.childNodes.length",
1379 empty: "!a.childNodes.length",
1382 contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
1385 visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1386 hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1389 enabled: "!a.disabled",
1390 disabled: "a.disabled",
1391 checked: "a.checked",
1392 selected: "a.selected || jQuery.attr(a, 'selected')",
1395 text: "a.type=='text'",
1396 radio: "a.type=='radio'",
1397 checkbox: "a.type=='checkbox'",
1398 file: "a.type=='file'",
1399 password: "a.type=='password'",
1400 submit: "a.type=='submit'",
1401 image: "a.type=='image'",
1402 reset: "a.type=='reset'",
1403 button: "a.type=='button'",
1404 input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)"
1406 ".": "jQuery.className.has(a,m[2])",
1410 "^=": "z && !z.indexOf(m[4])",
1411 "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
1412 "*=": "z && z.indexOf(m[4])>=0",
1415 "[": "jQuery.find(m[2],a).length"
1419 "\\.\\.|/\\.\\.", "a.parentNode",
1420 ">|/", "jQuery.sibling(a.firstChild)",
1421 "\\+", "jQuery.sibling(a).next",
1423 var s = jQuery.sibling(a);
1424 return s.n >= 0 ? s.slice(s.n+1) : [];
1430 * @type Array<Element>
1434 find: function( t, context ) {
1435 // Make sure that the context is a DOM Element
1436 if ( context && context.nodeType == undefined )
1439 // Set the correct context (if none is provided)
1440 context = context || jQuery.context || document;
1442 if ( t.constructor != String ) return [t];
1444 if ( !t.indexOf("//") ) {
1445 context = context.documentElement;
1446 t = t.substr(2,t.length);
1447 } else if ( !t.indexOf("/") ) {
1448 context = context.documentElement;
1449 t = t.substr(1,t.length);
1450 // FIX Assume the root element is right :(
1451 if ( t.indexOf("/") >= 1 )
1452 t = t.substr(t.indexOf("/"),t.length);
1455 var ret = [context];
1459 while ( t.length > 0 && last != t ) {
1463 t = jQuery.trim(t).replace( /^\/\//i, "" );
1465 var foundToken = false;
1467 for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1468 if ( foundToken ) continue;
1470 var re = new RegExp("^(" + jQuery.token[i] + ")");
1474 r = ret = jQuery.map( ret, jQuery.token[i+1] );
1475 t = jQuery.trim( t.replace( re, "" ) );
1480 if ( !foundToken ) {
1481 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1482 if ( ret[0] == context ) ret.shift();
1483 done = jQuery.merge( done, ret );
1484 r = ret = [context];
1485 t = " " + t.substr(1,t.length);
1487 var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1488 var m = re2.exec(t);
1490 if ( m[1] == "#" ) {
1491 // Ummm, should make this work in all XML docs
1492 var oid = document.getElementById(m[2]);
1493 r = ret = oid ? [oid] : [];
1494 t = t.replace( re2, "" );
1496 if ( !m[2] || m[1] == "." ) m[2] = "*";
1498 for ( var i = 0; i < ret.length; i++ )
1499 r = jQuery.merge( r,
1501 jQuery.getAll(ret[i]) :
1502 ret[i].getElementsByTagName(m[2])
1510 var val = jQuery.filter(t,r);
1512 t = jQuery.trim(val.t);
1516 if ( ret && ret[0] == context ) ret.shift();
1517 done = jQuery.merge( done, ret );
1522 getAll: function(o,r) {
1524 var s = o.childNodes;
1525 for ( var i = 0; i < s.length; i++ )
1526 if ( s[i].nodeType == 1 ) {
1528 jQuery.getAll( s[i], r );
1533 attr: function(elem, name, value){
1536 "class": "className",
1537 "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1538 cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1539 innerHTML: "innerHTML",
1540 className: "className",
1542 disabled: "disabled",
1544 readonly: "readOnly"
1547 // IE actually uses filters for opacity ... elem is actually elem.style
1548 if (name == "opacity" && jQuery.browser.msie && value != undefined) {
1549 // IE has trouble with opacity if it does not have layout
1550 // Would prefer to check element.hasLayout first but don't have access to the element here
1552 if (value == 1) // Remove filter to avoid more IE weirdness
1553 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
1555 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
1556 } else if (name == "opacity" && jQuery.browser.msie) {
1557 return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
1560 // Mozilla doesn't play well with opacity 1
1561 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
1564 if ( value != undefined ) elem[fix[name]] = value;
1565 return elem[fix[name]];
1566 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1567 return elem.getAttributeNode(name).nodeValue;
1568 } else if ( elem.tagName ) { // IE elem.getAttribute passes even for style
1569 if ( value != undefined ) elem.setAttribute( name, value );
1570 return elem.getAttribute( name );
1572 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1573 if ( value != undefined ) elem[name] = value;
1578 // The regular expressions that power the parsing engine
1580 // Match: [@value='test'], [@foo]
1581 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
1583 // Match: [div], [div p]
1584 "(\\[)\s*(.*?)\s*\\]",
1586 // Match: :contains('foo')
1587 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
1589 // Match: :even, :last-chlid
1593 filter: function(t,r,not) {
1594 // Figure out if we're doing regular, or inverse, filtering
1595 var g = not !== false ? jQuery.grep :
1596 function(a,f) {return jQuery.grep(a,f,true);};
1598 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1600 var p = jQuery.parse;
1602 for ( var i = 0; i < p.length; i++ ) {
1604 // Look for, and replace, string-like sequences
1605 // and finally build a regexp out of it
1606 var re = new RegExp(
1607 "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
1609 var m = re.exec( t );
1612 // Re-organize the first match
1614 m = ["",m[1], m[3], m[2], m[5]];
1616 // Remove what we just matched
1617 t = t.replace( re, "" );
1623 // :not() is a special case that can be optimized by
1624 // keeping it out of the expression list
1625 if ( m[1] == ":" && m[2] == "not" )
1626 r = jQuery.filter(m[3],r,false).r;
1628 // Otherwise, find the expression to execute
1630 var f = jQuery.expr[m[1]];
1631 if ( f.constructor != String )
1632 f = jQuery.expr[m[1]][m[2]];
1634 // Build a custom macro to enclose it
1635 eval("f = function(a,i){" +
1636 ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
1637 "return " + f + "}");
1639 // Execute it against the current filter
1644 // Return an array of filtered elements (r)
1645 // and the modified expression string (t)
1646 return { r: r, t: t };
1650 * Remove the whitespace from the beginning and end of a string.
1652 * @example $.trim(" hello, how are you? ");
1653 * @result "hello, how are you?"
1657 * @param String str The string to trim.
1661 return t.replace(/^\s+|\s+$/g, "");
1665 * All ancestors of a given element.
1669 * @type Array<Element>
1670 * @param Element elem The element to find the ancestors of.
1671 * @cat DOM/Traversing
1673 parents: function( elem ){
1675 var cur = elem.parentNode;
1676 while ( cur && cur != document ) {
1677 matched.push( cur );
1678 cur = cur.parentNode;
1684 * All elements on a specified axis.
1689 * @param Element elem The element to find all the siblings of (including itself).
1690 * @cat DOM/Traversing
1692 sibling: function(elem, pos, not) {
1696 var siblings = elem.parentNode.childNodes;
1697 for ( var i = 0; i < siblings.length; i++ ) {
1698 if ( not === true && siblings[i] == elem ) continue;
1700 if ( siblings[i].nodeType == 1 )
1701 elems.push( siblings[i] );
1702 if ( siblings[i] == elem )
1703 elems.n = elems.length - 1;
1707 return jQuery.extend( elems, {
1708 last: elems.n == elems.length - 1,
1709 cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
1710 prev: elems[elems.n - 1],
1711 next: elems[elems.n + 1]
1716 * Merge two arrays together, removing all duplicates. The final order
1717 * or the new array is: All the results from the first array, followed
1718 * by the unique results from the second array.
1720 * @example $.merge( [0,1,2], [2,3,4] )
1721 * @result [0,1,2,3,4]
1723 * @example $.merge( [3,2,1], [4,3,2] )
1728 * @param Array first The first array to merge.
1729 * @param Array second The second array to merge.
1732 merge: function(first, second) {
1735 // Move b over to the new array (this helps to avoid
1736 // StaticNodeList instances)
1737 for ( var k = 0; k < first.length; k++ )
1738 result[k] = first[k];
1740 // Now check for duplicates between a and b and only
1741 // add the unique items
1742 for ( var i = 0; i < second.length; i++ ) {
1743 var noCollision = true;
1745 // The collision-checking process
1746 for ( var j = 0; j < first.length; j++ )
1747 if ( second[i] == first[j] )
1748 noCollision = false;
1750 // If the item is unique, add it
1752 result.push( second[i] );
1759 * Filter items out of an array, by using a filter function.
1760 * The specified function will be passed two arguments: The
1761 * current array item and the index of the item in the array. The
1762 * function should return 'true' if you wish to keep the item in
1763 * the array, false if it should be removed.
1765 * @example $.grep( [0,1,2], function(i){
1772 * @param Array array The Array to find items in.
1773 * @param Function fn The function to process each item against.
1774 * @param Boolean inv Invert the selection - select the opposite of the function.
1777 grep: function(elems, fn, inv) {
1778 // If a string is passed in for the function, make a function
1779 // for it (a handy shortcut)
1780 if ( fn.constructor == String )
1781 fn = new Function("a","i","return " + fn);
1785 // Go through the array, only saving the items
1786 // that pass the validator function
1787 for ( var i = 0; i < elems.length; i++ )
1788 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1789 result.push( elems[i] );
1795 * Translate all items in an array to another array of items.
1796 * The translation function that is provided to this method is
1797 * called for each item in the array and is passed one argument:
1798 * The item to be translated. The function can then return:
1799 * The translated value, 'null' (to remove the item), or
1800 * an array of values - which will be flattened into the full array.
1802 * @example $.map( [0,1,2], function(i){
1807 * @example $.map( [0,1,2], function(i){
1808 * return i > 0 ? i + 1 : null;
1812 * @example $.map( [0,1,2], function(i){
1813 * return [ i, i + 1 ];
1815 * @result [0, 1, 1, 2, 2, 3]
1819 * @param Array array The Array to translate.
1820 * @param Function fn The function to process each item against.
1823 map: function(elems, fn) {
1824 // If a string is passed in for the function, make a function
1825 // for it (a handy shortcut)
1826 if ( fn.constructor == String )
1827 fn = new Function("a","return " + fn);
1831 // Go through the array, translating each of the items to their
1832 // new value (or values).
1833 for ( var i = 0; i < elems.length; i++ ) {
1834 var val = fn(elems[i],i);
1836 if ( val !== null && val != undefined ) {
1837 if ( val.constructor != Array ) val = [val];
1838 result = jQuery.merge( result, val );
1846 * A number of helper functions used for managing events.
1847 * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
1851 // Bind an event to an element
1852 // Original by Dean Edwards
1853 add: function(element, type, handler) {
1854 // For whatever reason, IE has trouble passing the window object
1855 // around, causing it to be cloned in the process
1856 if ( jQuery.browser.msie && element.setInterval != undefined )
1859 // Make sure that the function being executed has a unique ID
1860 if ( !handler.guid )
1861 handler.guid = this.guid++;
1863 // Init the element's event structure
1864 if (!element.events)
1865 element.events = {};
1867 // Get the current list of functions bound to this event
1868 var handlers = element.events[type];
1870 // If it hasn't been initialized yet
1872 // Init the event handler queue
1873 handlers = element.events[type] = {};
1875 // Remember an existing handler, if it's already there
1876 if (element["on" + type])
1877 handlers[0] = element["on" + type];
1880 // Add the function to the element's handler list
1881 handlers[handler.guid] = handler;
1883 // And bind the global event handler to the element
1884 element["on" + type] = this.handle;
1886 // Remember the function in a global list (for triggering)
1887 if (!this.global[type])
1888 this.global[type] = [];
1889 this.global[type].push( element );
1895 // Detach an event or set of events from an element
1896 remove: function(element, type, handler) {
1898 if (type && element.events[type])
1900 delete element.events[type][handler.guid];
1902 for ( var i in element.events[type] )
1903 delete element.events[type][i];
1905 for ( var j in element.events )
1906 this.remove( element, j );
1909 trigger: function(type,data,element) {
1910 // Clone the incoming data, if any
1911 data = $.merge([], data || []);
1913 // Handle a global trigger
1915 var g = this.global[type];
1917 for ( var i = 0; i < g.length; i++ )
1918 this.trigger( type, data, g[i] );
1920 // Handle triggering a single element
1921 } else if ( element["on" + type] ) {
1922 // Pass along a fake event
1923 data.unshift( this.fix({ type: type, target: element }) );
1925 // Trigger the event
1926 element["on" + type].apply( element, data );
1930 handle: function(event) {
1931 if ( typeof jQuery == "undefined" ) return false;
1933 event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data
1935 // If no correct event was found, fail
1936 if ( !event ) return false;
1938 var returnValue = true;
1940 var c = this.events[event.type];
1942 var args = [].slice.call( arguments, 1 );
1943 args.unshift( event );
1945 for ( var j in c ) {
1946 if ( c[j].apply( this, args ) === false ) {
1947 event.preventDefault();
1948 event.stopPropagation();
1949 returnValue = false;
1953 // Clean up added properties in IE to prevent memory leak
1954 if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = null;
1959 fix: function(event) {
1961 if(jQuery.browser.msie) {
1962 // fix target property
1963 event.target = event.srcElement;
1965 // check safari and if target is a textnode
1966 } else if(jQuery.browser.safari && event.target.nodeType == 3) {
1967 // target is readonly, clone the event object
1968 event = jQuery.extend({}, event);
1969 // get parentnode from textnode
1970 event.target = event.target.parentNode;
1973 // fix preventDefault and stopPropagation
1974 if (!event.preventDefault)
1975 event.preventDefault = function() {
1976 this.returnValue = false;
1979 if (!event.stopPropagation)
1980 event.stopPropagation = function() {
1981 this.cancelBubble = true;
1990 * Contains flags for the useragent, read from navigator.userAgent.
1991 * Available flags are: safari, opera, msie, mozilla
1992 * This property is available before the DOM is ready, therefore you can
1993 * use it to add ready events only for certain browsers.
1995 * See <a href="http://davecardwell.co.uk/geekery/javascript/jquery/jqbrowser/">
1996 * jQBrowser plugin</a> for advanced browser detection:
1998 * @example $.browser.msie
1999 * @desc returns true if the current useragent is some version of microsoft's internet explorer
2001 * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
2002 * @desc Alerts "this is safari!" only for safari browsers
2009 var b = navigator.userAgent.toLowerCase();
2011 // Figure out what browser is being used
2013 safari: /webkit/.test(b),
2014 opera: /opera/.test(b),
2015 msie: /msie/.test(b) && !/opera/.test(b),
2016 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
2019 // Check to see if the W3C box model is being used
2020 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
2026 * Append all of the matched elements to another, specified, set of elements.
2027 * This operation is, essentially, the reverse of doing a regular
2028 * $(A).append(B), in that instead of appending B to A, you're appending
2031 * @example $("p").appendTo("#foo");
2032 * @before <p>I would like to say: </p><div id="foo"></div>
2033 * @result <div id="foo"><p>I would like to say: </p></div>
2037 * @param String expr A jQuery expression of elements to match.
2038 * @cat DOM/Manipulation
2043 * Prepend all of the matched elements to another, specified, set of elements.
2044 * This operation is, essentially, the reverse of doing a regular
2045 * $(A).prepend(B), in that instead of prepending B to A, you're prepending
2048 * @example $("p").prependTo("#foo");
2049 * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
2050 * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
2054 * @param String expr A jQuery expression of elements to match.
2055 * @cat DOM/Manipulation
2057 prependTo: "prepend",
2060 * Insert all of the matched elements before another, specified, set of elements.
2061 * This operation is, essentially, the reverse of doing a regular
2062 * $(A).before(B), in that instead of inserting B before A, you're inserting
2065 * @example $("p").insertBefore("#foo");
2066 * @before <div id="foo">Hello</div><p>I would like to say: </p>
2067 * @result <p>I would like to say: </p><div id="foo">Hello</div>
2069 * @name insertBefore
2071 * @param String expr A jQuery expression of elements to match.
2072 * @cat DOM/Manipulation
2074 insertBefore: "before",
2077 * Insert all of the matched elements after another, specified, set of elements.
2078 * This operation is, essentially, the reverse of doing a regular
2079 * $(A).after(B), in that instead of inserting B after A, you're inserting
2082 * @example $("p").insertAfter("#foo");
2083 * @before <p>I would like to say: </p><div id="foo">Hello</div>
2084 * @result <div id="foo">Hello</div><p>I would like to say: </p>
2088 * @param String expr A jQuery expression of elements to match.
2089 * @cat DOM/Manipulation
2091 insertAfter: "after"
2095 * Get the current CSS width of the first matched element.
2097 * @example $("p").width();
2098 * @before <p>This is just a test.</p>
2107 * Set the CSS width of every matched element. Be sure to include
2108 * the "px" (or other unit of measurement) after the number that you
2109 * specify, otherwise you might get strange results.
2111 * @example $("p").width("20px");
2112 * @before <p>This is just a test.</p>
2113 * @result <p style="width:20px;">This is just a test.</p>
2117 * @param String val Set the CSS property to the specified value.
2122 * Get the current CSS height of the first matched element.
2124 * @example $("p").height();
2125 * @before <p>This is just a test.</p>
2134 * Set the CSS height of every matched element. Be sure to include
2135 * the "px" (or other unit of measurement) after the number that you
2136 * specify, otherwise you might get strange results.
2138 * @example $("p").height("20px");
2139 * @before <p>This is just a test.</p>
2140 * @result <p style="height:20px;">This is just a test.</p>
2144 * @param String val Set the CSS property to the specified value.
2149 * Get the current CSS top of the first matched element.
2151 * @example $("p").top();
2152 * @before <p>This is just a test.</p>
2161 * Set the CSS top of every matched element. Be sure to include
2162 * the "px" (or other unit of measurement) after the number that you
2163 * specify, otherwise you might get strange results.
2165 * @example $("p").top("20px");
2166 * @before <p>This is just a test.</p>
2167 * @result <p style="top:20px;">This is just a test.</p>
2171 * @param String val Set the CSS property to the specified value.
2176 * Get the current CSS left of the first matched element.
2178 * @example $("p").left();
2179 * @before <p>This is just a test.</p>
2188 * Set the CSS left of every matched element. Be sure to include
2189 * the "px" (or other unit of measurement) after the number that you
2190 * specify, otherwise you might get strange results.
2192 * @example $("p").left("20px");
2193 * @before <p>This is just a test.</p>
2194 * @result <p style="left:20px;">This is just a test.</p>
2198 * @param String val Set the CSS property to the specified value.
2203 * Get the current CSS position of the first matched element.
2205 * @example $("p").position();
2206 * @before <p>This is just a test.</p>
2215 * Set the CSS position of every matched element.
2217 * @example $("p").position("relative");
2218 * @before <p>This is just a test.</p>
2219 * @result <p style="position:relative;">This is just a test.</p>
2223 * @param String val Set the CSS property to the specified value.
2228 * Get the current CSS float of the first matched element.
2230 * @example $("p").float();
2231 * @before <p>This is just a test.</p>
2240 * Set the CSS float of every matched element.
2242 * @example $("p").float("left");
2243 * @before <p>This is just a test.</p>
2244 * @result <p style="float:left;">This is just a test.</p>
2248 * @param String val Set the CSS property to the specified value.
2253 * Get the current CSS overflow of the first matched element.
2255 * @example $("p").overflow();
2256 * @before <p>This is just a test.</p>
2265 * Set the CSS overflow of every matched element.
2267 * @example $("p").overflow("auto");
2268 * @before <p>This is just a test.</p>
2269 * @result <p style="overflow:auto;">This is just a test.</p>
2273 * @param String val Set the CSS property to the specified value.
2278 * Get the current CSS color of the first matched element.
2280 * @example $("p").color();
2281 * @before <p>This is just a test.</p>
2290 * Set the CSS color of every matched element.
2292 * @example $("p").color("blue");
2293 * @before <p>This is just a test.</p>
2294 * @result <p style="color:blue;">This is just a test.</p>
2298 * @param String val Set the CSS property to the specified value.
2303 * Get the current CSS background of the first matched element.
2305 * @example $("p").background();
2306 * @before <p style="background:blue;">This is just a test.</p>
2315 * Set the CSS background of every matched element.
2317 * @example $("p").background("blue");
2318 * @before <p>This is just a test.</p>
2319 * @result <p style="background:blue;">This is just a test.</p>
2323 * @param String val Set the CSS property to the specified value.
2327 css: "width,height,top,left,position,float,overflow,color,background".split(","),
2330 * Reduce the set of matched elements to a single element.
2331 * The position of the element in the set of matched elements
2332 * starts at 0 and goes to length - 1.
2334 * @example $("p").eq(1)
2335 * @before <p>This is just a test.</p><p>So is this</p>
2336 * @result [ <p>So is this</p> ]
2340 * @param Number pos The index of the element that you wish to limit to.
2345 * Reduce the set of matched elements to all elements before a given position.
2346 * The position of the element in the set of matched elements
2347 * starts at 0 and goes to length - 1.
2349 * @example $("p").lt(1)
2350 * @before <p>This is just a test.</p><p>So is this</p>
2351 * @result [ <p>This is just a test.</p> ]
2355 * @param Number pos Reduce the set to all elements below this position.
2360 * Reduce the set of matched elements to all elements after a given position.
2361 * The position of the element in the set of matched elements
2362 * starts at 0 and goes to length - 1.
2364 * @example $("p").gt(0)
2365 * @before <p>This is just a test.</p><p>So is this</p>
2366 * @result [ <p>So is this</p> ]
2370 * @param Number pos Reduce the set to all elements after this position.
2375 * Filter the set of elements to those that contain the specified text.
2377 * @example $("p").contains("test")
2378 * @before <p>This is just a test.</p><p>So is this</p>
2379 * @result [ <p>This is just a test.</p> ]
2383 * @param String str The string that will be contained within the text of an element.
2384 * @cat DOM/Traversing
2387 filter: [ "eq", "lt", "gt", "contains" ],
2391 * Get the current value of the first matched element.
2393 * @example $("input").val();
2394 * @before <input type="text" value="some text"/>
2395 * @result "some text"
2399 * @cat DOM/Attributes
2403 * Set the value of every matched element.
2405 * @example $("input").val("test");
2406 * @before <input type="text" value="some text"/>
2407 * @result <input type="text" value="test"/>
2411 * @param String val Set the property to the specified value.
2412 * @cat DOM/Attributes
2417 * Get the html contents of the first matched element.
2419 * @example $("div").html();
2420 * @before <div><input/></div>
2425 * @cat DOM/Attributes
2429 * Set the html contents of every matched element.
2431 * @example $("div").html("<b>new stuff</b>");
2432 * @before <div><input/></div>
2433 * @result <div><b>new stuff</b></div>
2437 * @param String val Set the html contents to the specified value.
2438 * @cat DOM/Attributes
2443 * Get the current id of the first matched element.
2445 * @example $("input").id();
2446 * @before <input type="text" id="test" value="some text"/>
2451 * @cat DOM/Attributes
2455 * Set the id of every matched element.
2457 * @example $("input").id("newid");
2458 * @before <input type="text" id="test" value="some text"/>
2459 * @result <input type="text" id="newid" value="some text"/>
2463 * @param String val Set the property to the specified value.
2464 * @cat DOM/Attributes
2469 * Get the current title of the first matched element.
2471 * @example $("img").title();
2472 * @before <img src="test.jpg" title="my image"/>
2473 * @result "my image"
2477 * @cat DOM/Attributes
2481 * Set the title of every matched element.
2483 * @example $("img").title("new title");
2484 * @before <img src="test.jpg" title="my image"/>
2485 * @result <img src="test.jpg" title="new image"/>
2489 * @param String val Set the property to the specified value.
2490 * @cat DOM/Attributes
2495 * Get the current name of the first matched element.
2497 * @example $("input").name();
2498 * @before <input type="text" name="username"/>
2499 * @result "username"
2503 * @cat DOM/Attributes
2507 * Set the name of every matched element.
2509 * @example $("input").name("user");
2510 * @before <input type="text" name="username"/>
2511 * @result <input type="text" name="user"/>
2515 * @param String val Set the property to the specified value.
2516 * @cat DOM/Attributes
2521 * Get the current href of the first matched element.
2523 * @example $("a").href();
2524 * @before <a href="test.html">my link</a>
2525 * @result "test.html"
2529 * @cat DOM/Attributes
2533 * Set the href of every matched element.
2535 * @example $("a").href("test2.html");
2536 * @before <a href="test.html">my link</a>
2537 * @result <a href="test2.html">my link</a>
2541 * @param String val Set the property to the specified value.
2542 * @cat DOM/Attributes
2547 * Get the current src of the first matched element.
2549 * @example $("img").src();
2550 * @before <img src="test.jpg" title="my image"/>
2551 * @result "test.jpg"
2555 * @cat DOM/Attributes
2559 * Set the src of every matched element.
2561 * @example $("img").src("test2.jpg");
2562 * @before <img src="test.jpg" title="my image"/>
2563 * @result <img src="test2.jpg" title="my image"/>
2567 * @param String val Set the property to the specified value.
2568 * @cat DOM/Attributes
2573 * Get the current rel of the first matched element.
2575 * @example $("a").rel();
2576 * @before <a href="test.html" rel="nofollow">my link</a>
2577 * @result "nofollow"
2581 * @cat DOM/Attributes
2585 * Set the rel of every matched element.
2587 * @example $("a").rel("nofollow");
2588 * @before <a href="test.html">my link</a>
2589 * @result <a href="test.html" rel="nofollow">my link</a>
2593 * @param String val Set the property to the specified value.
2594 * @cat DOM/Attributes
2601 * Get a set of elements containing the unique parents of the matched
2604 * @example $("p").parent()
2605 * @before <div><p>Hello</p><p>Hello</p></div>
2606 * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2610 * @cat DOM/Traversing
2614 * Get a set of elements containing the unique parents of the matched
2615 * set of elements, and filtered by an expression.
2617 * @example $("p").parent(".selected")
2618 * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2619 * @result [ <div class="selected"><p>Hello Again</p></div> ]
2623 * @param String expr An expression to filter the parents with
2624 * @cat DOM/Traversing
2626 parent: "a.parentNode",
2629 * Get a set of elements containing the unique ancestors of the matched
2630 * set of elements (except for the root element).
2632 * @example $("span").ancestors()
2633 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2634 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2638 * @cat DOM/Traversing
2642 * Get a set of elements containing the unique ancestors of the matched
2643 * set of elements, and filtered by an expression.
2645 * @example $("span").ancestors("p")
2646 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2647 * @result [ <p><span>Hello</span></p> ]
2651 * @param String expr An expression to filter the ancestors with
2652 * @cat DOM/Traversing
2654 ancestors: jQuery.parents,
2657 * Get a set of elements containing the unique ancestors of the matched
2658 * set of elements (except for the root element).
2660 * @example $("span").ancestors()
2661 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2662 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2666 * @cat DOM/Traversing
2670 * Get a set of elements containing the unique ancestors of the matched
2671 * set of elements, and filtered by an expression.
2673 * @example $("span").ancestors("p")
2674 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2675 * @result [ <p><span>Hello</span></p> ]
2679 * @param String expr An expression to filter the ancestors with
2680 * @cat DOM/Traversing
2682 parents: jQuery.parents,
2685 * Get a set of elements containing the unique next siblings of each of the
2686 * matched set of elements.
2688 * It only returns the very next sibling, not all next siblings.
2690 * @example $("p").next()
2691 * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2692 * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2696 * @cat DOM/Traversing
2700 * Get a set of elements containing the unique next siblings of each of the
2701 * matched set of elements, and filtered by an expression.
2703 * It only returns the very next sibling, not all next siblings.
2705 * @example $("p").next(".selected")
2706 * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2707 * @result [ <p class="selected">Hello Again</p> ]
2711 * @param String expr An expression to filter the next Elements with
2712 * @cat DOM/Traversing
2714 next: "jQuery.sibling(a).next",
2717 * Get a set of elements containing the unique previous siblings of each of the
2718 * matched set of elements.
2720 * It only returns the immediately previous sibling, not all previous siblings.
2722 * @example $("p").prev()
2723 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2724 * @result [ <div><span>Hello Again</span></div> ]
2728 * @cat DOM/Traversing
2732 * Get a set of elements containing the unique previous siblings of each of the
2733 * matched set of elements, and filtered by an expression.
2735 * It only returns the immediately previous sibling, not all previous siblings.
2737 * @example $("p").prev(".selected")
2738 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2739 * @result [ <div><span>Hello</span></div> ]
2743 * @param String expr An expression to filter the previous Elements with
2744 * @cat DOM/Traversing
2746 prev: "jQuery.sibling(a).prev",
2749 * Get a set of elements containing all of the unique siblings of each of the
2750 * matched set of elements.
2752 * @example $("div").siblings()
2753 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2754 * @result [ <p>Hello</p>, <p>And Again</p> ]
2758 * @cat DOM/Traversing
2762 * Get a set of elements containing all of the unique siblings of each of the
2763 * matched set of elements, and filtered by an expression.
2765 * @example $("div").siblings(".selected")
2766 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2767 * @result [ <p class="selected">Hello Again</p> ]
2771 * @param String expr An expression to filter the sibling Elements with
2772 * @cat DOM/Traversing
2774 siblings: "jQuery.sibling(a, null, true)",
2778 * Get a set of elements containing all of the unique children of each of the
2779 * matched set of elements.
2781 * @example $("div").children()
2782 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2783 * @result [ <span>Hello Again</span> ]
2787 * @cat DOM/Traversing
2791 * Get a set of elements containing all of the unique children of each of the
2792 * matched set of elements, and filtered by an expression.
2794 * @example $("div").children(".selected")
2795 * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2796 * @result [ <p class="selected">Hello Again</p> ]
2800 * @param String expr An expression to filter the child Elements with
2801 * @cat DOM/Traversing
2803 children: "jQuery.sibling(a.firstChild)"
2809 * Remove an attribute from each of the matched elements.
2811 * @example $("input").removeAttr("disabled")
2812 * @before <input disabled="disabled"/>
2817 * @param String name The name of the attribute to remove.
2820 removeAttr: function( key ) {
2821 this.removeAttribute( key );
2825 * Displays each of the set of matched elements if they are hidden.
2827 * @example $("p").show()
2828 * @before <p style="display: none">Hello</p>
2829 * @result [ <p style="display: block">Hello</p> ]
2836 this.style.display = this.oldblock ? this.oldblock : "";
2837 if ( jQuery.css(this,"display") == "none" )
2838 this.style.display = "block";
2842 * Hides each of the set of matched elements if they are shown.
2844 * @example $("p").hide()
2845 * @before <p>Hello</p>
2846 * @result [ <p style="display: none">Hello</p> ]
2848 * var pass = true, div = $("div");
2849 * div.hide().each(function(){
2850 * if ( this.style.display != "none" ) pass = false;
2852 * ok( pass, "Hide" );
2859 this.oldblock = this.oldblock || jQuery.css(this,"display");
2860 if ( this.oldblock == "none" )
2861 this.oldblock = "block";
2862 this.style.display = "none";
2866 * Toggles each of the set of matched elements. If they are shown,
2867 * toggle makes them hidden. If they are hidden, toggle
2870 * @example $("p").toggle()
2871 * @before <p>Hello</p><p style="display: none">Hello Again</p>
2872 * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2879 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2883 * Adds the specified class to each of the set of matched elements.
2885 * @example $("p").addClass("selected")
2886 * @before <p>Hello</p>
2887 * @result [ <p class="selected">Hello</p> ]
2891 * @param String class A CSS class to add to the elements
2894 addClass: function(c){
2895 jQuery.className.add(this,c);
2899 * Removes the specified class from the set of matched elements.
2901 * @example $("p").removeClass("selected")
2902 * @before <p class="selected">Hello</p>
2903 * @result [ <p>Hello</p> ]
2907 * @param String class A CSS class to remove from the elements
2910 removeClass: function(c){
2911 jQuery.className.remove(this,c);
2915 * Adds the specified class if it is not present, removes it if it is
2918 * @example $("p").toggleClass("selected")
2919 * @before <p>Hello</p><p class="selected">Hello Again</p>
2920 * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2924 * @param String class A CSS class with which to toggle the elements
2927 toggleClass: function( c ){
2928 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
2932 * Removes all matched elements from the DOM. This does NOT remove them from the
2933 * jQuery object, allowing you to use the matched elements further.
2935 * @example $("p").remove();
2936 * @before <p>Hello</p> how are <p>you?</p>
2941 * @cat DOM/Manipulation
2945 * Removes only elements (out of the list of matched elements) that match
2946 * the specified jQuery expression. This does NOT remove them from the
2947 * jQuery object, allowing you to use the matched elements further.
2949 * @example $("p").remove(".hello");
2950 * @before <p class="hello">Hello</p> how are <p>you?</p>
2951 * @result how are <p>you?</p>
2955 * @param String expr A jQuery expression to filter elements by.
2956 * @cat DOM/Manipulation
2958 remove: function(a){
2959 if ( !a || jQuery.filter( a, [this] ).r )
2960 this.parentNode.removeChild( this );
2964 * Removes all child nodes from the set of matched elements.
2966 * @example $("p").empty()
2967 * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2968 * @result [ <p></p> ]
2972 * @cat DOM/Manipulation
2975 while ( this.firstChild )
2976 this.removeChild( this.firstChild );
2980 * Binds a handler to a particular event (like click) for each matched element.
2981 * The event handler is passed an event object that you can use to prevent
2982 * default behaviour. To stop both default action and event bubbling, your handler
2983 * has to return false.
2985 * @example $("p").bind( "click", function() {
2986 * alert( $(this).text() );
2988 * @before <p>Hello</p>
2989 * @result alert("Hello")
2991 * @example $("form").bind( "submit", function() { return false; } )
2992 * @desc Cancel a default action and prevent it from bubbling by returning false
2993 * from your function.
2995 * @example $("form").bind( "submit", function(event) {
2996 * event.preventDefault();
2998 * @desc Cancel only the default action by using the preventDefault method.
3001 * @example $("form").bind( "submit", function(event) {
3002 * event.stopPropagation();
3004 * @desc Stop only an event from bubbling by using the stopPropagation method.
3008 * @param String type An event type
3009 * @param Function fn A function to bind to the event on each of the set of matched elements
3012 bind: function( type, fn ) {
3013 if ( fn.constructor == String )
3014 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
3015 jQuery.event.add( this, type, fn );
3019 * The opposite of bind, removes a bound event from each of the matched
3020 * elements. You must pass the identical function that was used in the original
3023 * @example $("p").unbind( "click", function() { alert("Hello"); } )
3024 * @before <p onclick="alert('Hello');">Hello</p>
3025 * @result [ <p>Hello</p> ]
3029 * @param String type An event type
3030 * @param Function fn A function to unbind from the event on each of the set of matched elements
3035 * Removes all bound events of a particular type from each of the matched
3038 * @example $("p").unbind( "click" )
3039 * @before <p onclick="alert('Hello');">Hello</p>
3040 * @result [ <p>Hello</p> ]
3044 * @param String type An event type
3049 * Removes all bound events from each of the matched elements.
3051 * @example $("p").unbind()
3052 * @before <p onclick="alert('Hello');">Hello</p>
3053 * @result [ <p>Hello</p> ]
3059 unbind: function( type, fn ) {
3060 jQuery.event.remove( this, type, fn );
3064 * Trigger a type of event on every matched element.
3066 * @example $("p").trigger("click")
3067 * @before <p click="alert('hello')">Hello</p>
3068 * @result alert('hello')
3072 * @param String type An event type to trigger.
3075 trigger: function( type, data ) {
3076 jQuery.event.trigger( type, data, this );