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
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
32 // Watch for when a jQuery object is passed as the selector
34 return jQuery( jQuery.makeArray( 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 ( typeof a == "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.set( 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.makeArray( 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" )
72 // Map the jQuery namespace to the '$' one
76 * This function accepts a string containing a CSS or
77 * basic XPath selector which is then used to match a set of elements.
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
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 $("input:radio", document.forms[0])
94 * @desc Searches for all inputs of type radio within the first form in the document
96 * @example $("div", xml.responseXML)
97 * @desc This finds all div elements within the specified XML document.
100 * @param String expr An expression to search with
101 * @param Element context (optional) A DOM Element, or Document, representing the base context.
105 * @see $(Element<Array>)
109 * This function accepts a string of raw HTML.
111 * The HTML string is different from the traditional selectors in that
112 * it creates the DOM elements representing that HTML string, on the fly,
113 * to be (assumedly) inserted into the document later.
115 * @example $("<div><p>Hello</p></div>").appendTo("#body")
116 * @desc Creates a div element (and all of its contents) dynamically,
117 * and appends it to the element with the ID of body. Internally, an
118 * element is created and it's innerHTML property set to the given markup.
119 * It is therefore both quite flexible and limited.
122 * @param String html A string of HTML to create on the fly.
128 * Wrap jQuery functionality around a specific DOM Element.
129 * This function also accepts XML Documents and Window objects
130 * as valid arguments (even though they are not DOM Elements).
132 * @example $(document).find("div > p")
133 * @before <p>one</p> <div><p>two</p></div> <p>three</p>
134 * @result [ <p>two</p> ]
136 * @example $(document.body).background( "black" );
137 * @desc Sets the background color of the page to black.
140 * @param Element elem A DOM element to be encapsulated by a jQuery object.
146 * Wrap jQuery functionality around a set of DOM Elements.
148 * @example $( myForm.elements ).hide()
149 * @desc Hides all the input elements within a form
152 * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
158 * A shorthand for $(document).ready(), allowing you to bind a function
159 * to be executed when the DOM document has finished loading. This function
160 * behaves just like $(document).ready(), in that it should be used to wrap
161 * all of the other $() operations on your page. While this function is,
162 * technically, chainable - there really isn't much use for chaining against it.
163 * You can have as many $(document).ready events on your page as you like.
165 * See ready(Function) for details about the ready event.
167 * @example $(function(){
168 * // Document is ready
170 * @desc Executes the function when the DOM is ready to be used.
173 * @param Function fn The function to execute when the DOM is ready.
179 * A means of creating a cloned copy of a jQuery object. This function
180 * copies the set of matched elements from one jQuery object and creates
181 * another, new, jQuery object containing the same elements.
183 * @example var div = $("div");
184 * $( div ).find("p");
185 * @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).
188 * @param jQuery obj The jQuery object to be cloned.
193 jQuery.fn = jQuery.prototype = {
195 * The current version of jQuery.
206 * The number of elements currently matched.
208 * @example $("img").length;
209 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
219 * The number of elements currently matched.
221 * @example $("img").size();
222 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
234 * Access all matched elements. This serves as a backwards-compatible
235 * way of accessing all matched elements (other than the jQuery object
236 * itself, which is, in fact, an array of elements).
238 * @example $("img").get();
239 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
240 * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
243 * @type Array<Element>
248 * Access a single matched element. num is used to access the
249 * Nth element matched.
251 * @example $("img").get(1);
252 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
253 * @result [ <img src="test1.jpg"/> ]
257 * @param Number num Access the element in the Nth position.
260 get: function( num ) {
261 return num == undefined ?
263 // Return a 'clean' array
264 jQuery.makeArray( this ) :
266 // Return just the object
271 * Set the jQuery object to an array of elements.
273 * @example $("img").set([ document.body ]);
274 * @result $("img").set() == [ document.body ]
279 * @param Elements elems An array of elements
282 set: function( array ) {
283 // Use a tricky hack to make the jQuery object
284 // look and feel like an array
286 [].push.apply( this, array );
291 * Execute a function within the context of every matched element.
292 * This means that every time the passed-in function is executed
293 * (which is once for every element matched) the 'this' keyword
294 * points to the specific element.
296 * Additionally, the function, when executed, is passed a single
297 * argument representing the position of the element in the matched
300 * @example $("img").each(function(i){
301 * this.src = "test" + i + ".jpg";
303 * @before <img/> <img/>
304 * @result <img src="test0.jpg"/> <img src="test1.jpg"/>
305 * @desc Iterates over two images and sets their src property
309 * @param Function fn A function to execute
312 each: function( fn, args ) {
313 return jQuery.each( this, fn, args );
317 * Searches every matched element for the object and returns
318 * the index of the element, if found, starting with zero.
319 * Returns -1 if the object wasn't found.
321 * @example $("*").index(document.getElementById('foobar'))
322 * @before <div id="foobar"></div><b></b><span id="foo"></span>
325 * @example $("*").index(document.getElementById('foo'))
326 * @before <div id="foobar"></div><b></b><span id="foo"></span>
329 * @example $("*").index(document.getElementById('bar'))
330 * @before <div id="foobar"></div><b></b><span id="foo"></span>
335 * @param Object obj Object to search for
338 index: function( obj ) {
340 this.each(function(i){
341 if ( this == obj ) pos = i;
347 * Access a property on the first matched element.
348 * This method makes it easy to retrieve a property value
349 * from the first matched element.
351 * @example $("img").attr("src");
352 * @before <img src="test.jpg"/>
357 * @param String name The name of the property to access.
362 * Set a hash of key/value object properties to all matched elements.
363 * This serves as the best way to set a large number of properties
364 * on all matched elements.
366 * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
368 * @result <img src="test.jpg" alt="Test Image"/>
372 * @param Hash prop A set of key/value pairs to set as object properties.
377 * Set a single property to a value, on all matched elements.
379 * Note that you can't set the name property of input elements in IE.
380 * Use $(html) or $().append(html) or $().html(html) to create elements
381 * on the fly including the name property.
383 * @example $("img").attr("src","test.jpg");
385 * @result <img src="test.jpg"/>
389 * @param String key The name of the property to set.
390 * @param Object value The value to set the property to.
393 attr: function( key, value, type ) {
394 // Check to see if we're setting style values
395 return typeof key != "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 )
402 type ? this.style : this,
406 // See if we're setting a single key/value style
409 type ? this.style : this,
414 // Look for the case where we're accessing a style value
415 jQuery[ type || "attr" ]( this[0], key );
419 * Access a style property on the first matched element.
420 * This method makes it easy to retrieve a style property value
421 * from the first matched element.
423 * @example $("p").css("color");
424 * @before <p style="color:red;">Test Paragraph.</p>
426 * @desc Retrieves the color style of the first paragraph
428 * @example $("p").css("fontWeight");
429 * @before <p style="font-weight: bold;">Test Paragraph.</p>
431 * @desc Retrieves the font-weight style of the first paragraph.
432 * Note that for all style properties with a dash (like 'font-weight'), you have to
433 * write it in camelCase. In other words: Every time you have a '-' in a
434 * property, remove it and replace the next character with an uppercase
435 * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
436 * borderStyle, borderBottomWidth etc.
440 * @param String name The name of the property to access.
445 * Set a hash of key/value style properties to all matched elements.
446 * This serves as the best way to set a large number of style properties
447 * on all matched elements.
449 * @example $("p").css({ color: "red", background: "blue" });
450 * @before <p>Test Paragraph.</p>
451 * @result <p style="color:red; background:blue;">Test Paragraph.</p>
455 * @param Hash prop A set of key/value pairs to set as style properties.
460 * Set a single style property to a value, on all matched elements.
462 * @example $("p").css("color","red");
463 * @before <p>Test Paragraph.</p>
464 * @result <p style="color:red;">Test Paragraph.</p>
465 * @desc Changes the color of all paragraphs to red
469 * @param String key The name of the property to set.
470 * @param Object value The value to set the property to.
473 css: function( key, value ) {
474 return this.attr( key, value, "curCSS" );
478 * Retrieve the text contents of all matched elements. The result is
479 * a string that contains the combined text contents of all matched
480 * elements. This method works on both HTML and XML documents.
482 * @example $("p").text();
483 * @before <p>Test Paragraph.</p>
484 * @result Test Paragraph.
492 * Set the text contents of all matched elements. This has the same
493 * effect as calling .html() with your specified string.
495 * @example $("p").text("Some new text.");
496 * @before <p>Test Paragraph.</p>
497 * @result <p>Some new text.</p>
499 * @param String val The text value to set the contents of the element to.
506 // A surprisingly high number of people expect the
507 // .text() method to do this, so lets do it!
508 if ( typeof e == "string" )
509 return this.html( e );
513 for ( var j = 0, el = e.length; j < el; j++ ) {
514 var r = e[j].childNodes;
515 for ( var i = 0, rl = r.length; i < rl; i++ )
516 if ( r[i].nodeType != 8 )
517 t += r[i].nodeType != 1 ?
518 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
524 * Wrap all matched elements with a structure of other elements.
525 * This wrapping process is most useful for injecting additional
526 * stucture into a document, without ruining the original semantic
527 * qualities of a document.
529 * This works by going through the first element
530 * provided (which is generated, on the fly, from the provided HTML)
531 * and finds the deepest ancestor element within its
532 * structure - it is that element that will en-wrap everything else.
534 * This does not work with elements that contain text. Any necessary text
535 * must be added after the wrapping is done.
537 * @example $("p").wrap("<div class='wrap'></div>");
538 * @before <p>Test Paragraph.</p>
539 * @result <div class='wrap'><p>Test Paragraph.</p></div>
543 * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
544 * @cat DOM/Manipulation
548 * Wrap all matched elements with a structure of other elements.
549 * This wrapping process is most useful for injecting additional
550 * stucture into a document, without ruining the original semantic
551 * qualities of a document.
553 * This works by going through the first element
554 * provided and finding the deepest ancestor element within its
555 * structure - it is that element that will en-wrap everything else.
557 * This does not work with elements that contain text. Any necessary text
558 * must be added after the wrapping is done.
560 * @example $("p").wrap( document.getElementById('content') );
561 * @before <p>Test Paragraph.</p><div id="content"></div>
562 * @result <div id="content"><p>Test Paragraph.</p></div>
566 * @param Element elem A DOM element that will be wrapped.
567 * @cat DOM/Manipulation
570 // The elements to wrap the target around
571 var a = jQuery.clean(arguments);
573 // Wrap each of the matched elements individually
574 return this.each(function(){
575 // Clone the structure that we're using to wrap
576 var b = a[0].cloneNode(true);
578 // Insert it before the element to be wrapped
579 this.parentNode.insertBefore( b, this );
581 // Find the deepest point in the wrap structure
582 while ( b.firstChild )
585 // Move the matched element to within the wrap structure
586 b.appendChild( this );
591 * Append any number of elements to the inside of every matched elements,
592 * generated from the provided HTML.
593 * This operation is similar to doing an appendChild to all the
594 * specified elements, adding them into the document.
596 * @example $("p").append("<b>Hello</b>");
597 * @before <p>I would like to say: </p>
598 * @result <p>I would like to say: <b>Hello</b></p>
602 * @param String html A string of HTML, that will be created on the fly and appended to the target.
603 * @cat DOM/Manipulation
607 * Append an element to the inside of all matched elements.
608 * This operation is similar to doing an appendChild to all the
609 * specified elements, adding them into the document.
611 * @example $("p").append( $("#foo")[0] );
612 * @before <p>I would like to say: </p><b id="foo">Hello</b>
613 * @result <p>I would like to say: <b id="foo">Hello</b></p>
617 * @param Element elem A DOM element that will be appended.
618 * @cat DOM/Manipulation
622 * Append any number of elements to the inside of all matched elements.
623 * This operation is similar to doing an appendChild to all the
624 * specified elements, adding them into the document.
626 * @example $("p").append( $("b") );
627 * @before <p>I would like to say: </p><b>Hello</b>
628 * @result <p>I would like to say: <b>Hello</b></p>
632 * @param Array<Element> elems An array of elements, all of which will be appended.
633 * @cat DOM/Manipulation
636 return this.domManip(arguments, true, 1, function(a){
637 this.appendChild( a );
642 * Prepend any number of elements to the inside of every matched elements,
643 * generated from the provided HTML.
644 * This operation is the best way to insert dynamically created elements
645 * inside, at the beginning, of all the matched element.
647 * @example $("p").prepend("<b>Hello</b>");
648 * @before <p>I would like to say: </p>
649 * @result <p><b>Hello</b>I would like to say: </p>
653 * @param String html A string of HTML, that will be created on the fly and appended to the target.
654 * @cat DOM/Manipulation
658 * Prepend an element to the inside of all matched elements.
659 * This operation is the best way to insert an element inside, at the
660 * beginning, of all the matched element.
662 * @example $("p").prepend( $("#foo")[0] );
663 * @before <p>I would like to say: </p><b id="foo">Hello</b>
664 * @result <p><b id="foo">Hello</b>I would like to say: </p>
668 * @param Element elem A DOM element that will be appended.
669 * @cat DOM/Manipulation
673 * Prepend any number of elements to the inside of all matched elements.
674 * This operation is the best way to insert a set of elements inside, at the
675 * beginning, of all the matched element.
677 * @example $("p").prepend( $("b") );
678 * @before <p>I would like to say: </p><b>Hello</b>
679 * @result <p><b>Hello</b>I would like to say: </p>
683 * @param Array<Element> elems An array of elements, all of which will be appended.
684 * @cat DOM/Manipulation
686 prepend: function() {
687 return this.domManip(arguments, true, -1, function(a){
688 this.insertBefore( a, this.firstChild );
693 * Insert any number of dynamically generated elements before each of the
696 * @example $("p").before("<b>Hello</b>");
697 * @before <p>I would like to say: </p>
698 * @result <b>Hello</b><p>I would like to say: </p>
702 * @param String html A string of HTML, that will be created on the fly and appended to the target.
703 * @cat DOM/Manipulation
707 * Insert an element before each of the matched elements.
709 * @example $("p").before( $("#foo")[0] );
710 * @before <p>I would like to say: </p><b id="foo">Hello</b>
711 * @result <b id="foo">Hello</b><p>I would like to say: </p>
715 * @param Element elem A DOM element that will be appended.
716 * @cat DOM/Manipulation
720 * Insert any number of elements before each of the matched elements.
722 * @example $("p").before( $("b") );
723 * @before <p>I would like to say: </p><b>Hello</b>
724 * @result <b>Hello</b><p>I would like to say: </p>
728 * @param Array<Element> elems An array of elements, all of which will be appended.
729 * @cat DOM/Manipulation
732 return this.domManip(arguments, false, 1, function(a){
733 this.parentNode.insertBefore( a, this );
738 * Insert any number of dynamically generated elements after each of the
741 * @example $("p").after("<b>Hello</b>");
742 * @before <p>I would like to say: </p>
743 * @result <p>I would like to say: </p><b>Hello</b>
747 * @param String html A string of HTML, that will be created on the fly and appended to the target.
748 * @cat DOM/Manipulation
752 * Insert an element after each of the matched elements.
754 * @example $("p").after( $("#foo")[0] );
755 * @before <b id="foo">Hello</b><p>I would like to say: </p>
756 * @result <p>I would like to say: </p><b id="foo">Hello</b>
760 * @param Element elem A DOM element that will be appended.
761 * @cat DOM/Manipulation
765 * Insert any number of elements after each of the matched elements.
767 * @example $("p").after( $("b") );
768 * @before <b>Hello</b><p>I would like to say: </p>
769 * @result <p>I would like to say: </p><b>Hello</b>
773 * @param Array<Element> elems An array of elements, all of which will be appended.
774 * @cat DOM/Manipulation
777 return this.domManip(arguments, false, -1, function(a){
778 this.parentNode.insertBefore( a, this.nextSibling );
783 * End the most recent 'destructive' operation, reverting the list of matched elements
784 * back to its previous state. After an end operation, the list of matched elements will
785 * revert to the last state of matched elements.
787 * @example $("p").find("span").end();
788 * @before <p><span>Hello</span>, how are you?</p>
789 * @result $("p").find("span").end() == [ <p>...</p> ]
793 * @cat DOM/Traversing
796 if( !(this.stack && this.stack.length) )
798 return this.set( this.stack.pop() );
802 * Searches for all elements that match the specified expression.
803 * This method is the optimal way of finding additional descendant
804 * elements with which to process.
806 * All searching is done using a jQuery expression. The expression can be
807 * written using CSS 1-3 Selector syntax, or basic XPath.
809 * @example $("p").find("span");
810 * @before <p><span>Hello</span>, how are you?</p>
811 * @result $("p").find("span") == [ <span>Hello</span> ]
815 * @param String expr An expression to search with.
816 * @cat DOM/Traversing
819 return this.pushStack( jQuery.map( this, function(a){
820 return jQuery.find(t,a);
825 * Create cloned copies of all matched DOM Elements. This does
826 * not create a cloned copy of this particular jQuery object,
827 * instead it creates duplicate copies of all DOM Elements.
828 * This is useful for moving copies of the elements to another
829 * location in the DOM.
831 * @example $("b").clone().prependTo("p");
832 * @before <b>Hello</b><p>, how are you?</p>
833 * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
837 * @cat DOM/Manipulation
839 clone: function(deep) {
840 return this.pushStack( jQuery.map( this, function(a){
841 return a.cloneNode( deep != undefined ? deep : true );
846 * Removes all elements from the set of matched elements that do not
847 * match the specified expression. This method is used to narrow down
848 * the results of a search.
850 * All searching is done using a jQuery expression. The expression
851 * can be written using CSS 1-3 Selector syntax, or basic XPath.
853 * @example $("p").filter(".selected")
854 * @before <p class="selected">Hello</p><p>How are you?</p>
855 * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
859 * @param String expr An expression to search with.
860 * @cat DOM/Traversing
864 * Removes all elements from the set of matched elements that do not
865 * match at least one of the expressions passed to the function. This
866 * method is used when you want to filter the set of matched elements
867 * through more than one expression.
869 * Elements will be retained in the jQuery object if they match at
870 * least one of the expressions passed.
872 * @example $("p").filter([".selected", ":first"])
873 * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
874 * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
878 * @param Array<String> exprs A set of expressions to evaluate against
879 * @cat DOM/Traversing
881 filter: function(t) {
882 return this.pushStack(
883 t.constructor == Array &&
884 jQuery.map(this,function(a){
885 for ( var i = 0, tl = t.length; i < tl; i++ )
886 if ( jQuery.filter(t[i],[a]).r.length )
891 t.constructor == Boolean &&
892 ( t ? this.get() : [] ) ||
894 typeof t == "function" &&
895 jQuery.grep( this, t ) ||
897 jQuery.filter(t,this).r, arguments );
901 * Removes the specified Element from the set of matched elements. This
902 * method is used to remove a single Element from a jQuery object.
904 * @example $("p").not( document.getElementById("selected") )
905 * @before <p>Hello</p><p id="selected">Hello Again</p>
906 * @result [ <p>Hello</p> ]
910 * @param Element el An element to remove from the set
911 * @cat DOM/Traversing
915 * Removes elements matching the specified expression from the set
916 * of matched elements. This method is used to remove one or more
917 * elements from a jQuery object.
919 * @example $("p").not("#selected")
920 * @before <p>Hello</p><p id="selected">Hello Again</p>
921 * @result [ <p>Hello</p> ]
925 * @param String expr An expression with which to remove matching elements
926 * @cat DOM/Traversing
929 return this.pushStack( typeof t == "string" ?
930 jQuery.filter(t,this,true).r :
931 jQuery.grep(this,function(a){ return a != t; }), arguments );
935 * Adds the elements matched by the expression to the jQuery object. This
936 * can be used to concatenate the result sets of two expressions.
938 * @example $("p").add("span")
939 * @before <p>Hello</p><p><span>Hello Again</span></p>
940 * @result [ <p>Hello</p>, <span>Hello Again</span> ]
944 * @param String expr An expression whose matched elements are added
945 * @cat DOM/Traversing
949 * Adds each of the Elements in the array to the set of matched elements.
950 * This is used to add a set of Elements to a jQuery object.
952 * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
953 * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
954 * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
958 * @param Array<Element> els An array of Elements to add
959 * @cat DOM/Traversing
963 * Adds a single Element to the set of matched elements. This is used to
964 * add a single Element to a jQuery object.
966 * @example $("p").add( document.getElementById("a") )
967 * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
968 * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
972 * @param Element el An Element to add
973 * @cat DOM/Traversing
976 return this.pushStack( jQuery.merge(
977 this.get(), typeof t == "string" ?
979 t.constructor == Array ? t : [t] ), arguments );
983 * Checks the current selection against an expression and returns true,
984 * if at least one element of the selection fits the given expression.
985 * Does return false, if no element fits or the expression is not valid.
987 * @example $("input[@type='checkbox']").parent().is("form")
988 * @before <form><input type="checkbox" /></form>
990 * @desc Returns true, because the parent of the input is a form element
992 * @example $("input[@type='checkbox']").parent().is("form")
993 * @before <form><p><input type="checkbox" /></p></form>
995 * @desc Returns false, because the parent of the input is a p element
997 * @example $("form").is(null)
998 * @before <form></form>
1000 * @desc An invalid expression always returns false.
1004 * @param String expr The expression with which to filter
1005 * @cat DOM/Traversing
1007 is: function(expr) {
1008 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1015 * @param Boolean table Insert TBODY in TABLEs if one is not found.
1016 * @param Number dir If dir<0, process args in reverse order.
1017 * @param Function fn The function doing the DOM manipulation.
1021 domManip: function(args, table, dir, fn){
1022 var clone = this.length > 1;
1023 var a = jQuery.clean(args);
1027 return this.each(function(){
1030 if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1031 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1033 for ( var i = 0, al = a.length; i < al; i++ )
1034 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1049 pushStack: function(a,args) {
1050 var fn = args && args.length > 1 && args[args.length-1];
1051 var fn2 = args && args.length > 2 && args[args.length-2];
1053 if ( fn && fn.constructor != Function ) fn = null;
1054 if ( fn2 && fn2.constructor != Function ) fn2 = null;
1057 if ( !this.stack ) this.stack = [];
1058 this.stack.push( this.get() );
1061 var old = this.get();
1064 if ( fn2 && a.length || !fn2 )
1065 this.each( fn2 || fn ).set( old );
1067 this.set( old ).each( fn );
1075 * Extends the jQuery object itself. Can be used to add functions into
1076 * the jQuery namespace and to add plugin methods (plugins).
1078 * @example jQuery.fn.extend({
1079 * check: function() {
1080 * return this.each(function() { this.checked = true; });
1082 * uncheck: function() {
1083 * return this.each(function() { this.checked = false; });
1086 * $("input[@type=checkbox]").check();
1087 * $("input[@type=radio]").uncheck();
1088 * @desc Adds two plugin methods.
1090 * @example jQuery.extend({
1091 * min: function(a, b) { return a < b ? a : b; },
1092 * max: function(a, b) { return a > b ? a : b; }
1094 * @desc Adds two functions into the jQuery namespace
1097 * @param Object prop The object that will be merged into the jQuery object
1103 * Extend one object with one or more others, returning the original,
1104 * modified, object. This is a great utility for simple inheritance.
1106 * @example var settings = { validate: false, limit: 5, name: "foo" };
1107 * var options = { validate: true, name: "bar" };
1108 * jQuery.extend(settings, options);
1109 * @result settings == { validate: true, limit: 5, name: "bar" }
1110 * @desc Merge settings and options, modifying settings
1112 * @example var defaults = { validate: false, limit: 5, name: "foo" };
1113 * var options = { validate: true, name: "bar" };
1114 * var settings = jQuery.extend({}, defaults, options);
1115 * @result settings == { validate: true, limit: 5, name: "bar" }
1116 * @desc Merge defaults and options, without modifying the defaults
1119 * @param Object target The object to extend
1120 * @param Object prop1 The object that will be merged into the first.
1121 * @param Object propN (optional) More objects to merge into the first
1125 jQuery.extend = jQuery.fn.extend = function() {
1126 // copy reference to target object
1127 var target = arguments[0],
1130 // extend jQuery itself if only one argument is passed
1131 if ( arguments.length == 1 ) {
1136 while (prop = arguments[a++])
1137 // Extend the base object
1138 for ( var i in prop ) target[i] = prop[i];
1140 // Return the modified object
1152 jQuery.initDone = true;
1154 jQuery.each( jQuery.macros.axis, function(i,n){
1155 jQuery.fn[ i ] = function(a) {
1156 var ret = jQuery.map(this,n);
1157 if ( a && typeof a == "string" )
1158 ret = jQuery.filter(a,ret).r;
1159 return this.pushStack( ret, arguments );
1163 jQuery.each( jQuery.macros.to, function(i,n){
1164 jQuery.fn[ i ] = function(){
1166 return this.each(function(){
1167 for ( var j = 0, al = a.length; j < al; j++ )
1168 jQuery(a[j])[n]( this );
1173 jQuery.each( jQuery.macros.each, function(i,n){
1174 jQuery.fn[ i ] = function() {
1175 return this.each( n, arguments );
1179 jQuery.each( jQuery.macros.filter, function(i,n){
1180 jQuery.fn[ n ] = function(num,fn) {
1181 return this.filter( ":" + n + "(" + num + ")", fn );
1185 jQuery.each( jQuery.macros.attr, function(i,n){
1187 jQuery.fn[ i ] = function(h) {
1188 return h == undefined ?
1189 this.length ? this[0][n] : null :
1194 jQuery.each( jQuery.macros.css, function(i,n){
1195 jQuery.fn[ n ] = function(h) {
1196 return h == undefined ?
1197 ( this.length ? jQuery.css( this[0], n ) : null ) :
1205 * A generic iterator function, which can be used to seemlessly
1206 * iterate over both objects and arrays. This function is not the same
1207 * as $().each() - which is used to iterate, exclusively, over a jQuery
1208 * object. This function can be used to iterate over anything.
1210 * @example $.each( [0,1,2], function(i){
1211 * alert( "Item #" + i + ": " + this );
1213 * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
1215 * @example $.each( { name: "John", lang: "JS" }, function(i){
1216 * alert( "Name: " + i + ", Value: " + this );
1218 * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
1221 * @param Object obj The object, or array, to iterate over.
1222 * @param Function fn The function that will be executed on every object.
1226 // args is for internal usage only
1227 each: function( obj, fn, args ) {
1228 if ( obj.length == undefined )
1229 for ( var i in obj )
1230 fn.apply( obj[i], args || [i, obj[i]] );
1232 for ( var i = 0, ol = obj.length; i < ol; i++ )
1233 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1238 add: function( elem, c ){
1239 jQuery.each( c.split(/\s+/), function(i, cur){
1240 if ( !jQuery.className.has( elem.className, cur ) )
1241 elem.className += ( elem.className ? " " : "" ) + cur;
1244 remove: function( elem, c ){
1245 elem.className = c ?
1246 jQuery.grep( elem.className.split(/\s+/), function(cur){
1247 return !jQuery.className.has( c, cur );
1250 has: function( classes, c ){
1251 return classes && new RegExp("(^|\\s)" + c + "(\\s|$)").test( classes );
1256 * Swap in/out style options.
1259 swap: function(e,o,f) {
1260 for ( var i in o ) {
1261 e.style["old"+i] = e.style[i];
1266 e.style[i] = e.style["old"+i];
1269 css: function(e,p) {
1270 if ( p == "height" || p == "width" ) {
1271 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1273 for ( var i = 0, dl = d.length; i < dl; i++ ) {
1274 old["padding" + d[i]] = 0;
1275 old["border" + d[i] + "Width"] = 0;
1278 jQuery.swap( e, old, function() {
1279 if (jQuery.css(e,"display") != "none") {
1280 oHeight = e.offsetHeight;
1281 oWidth = e.offsetWidth;
1283 e = jQuery(e.cloneNode(true))
1284 .find(":radio").removeAttr("checked").end()
1286 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1287 }).appendTo(e.parentNode)[0];
1289 var parPos = jQuery.css(e.parentNode,"position");
1290 if ( parPos == "" || parPos == "static" )
1291 e.parentNode.style.position = "relative";
1293 oHeight = e.clientHeight;
1294 oWidth = e.clientWidth;
1296 if ( parPos == "" || parPos == "static" )
1297 e.parentNode.style.position = "static";
1299 e.parentNode.removeChild(e);
1303 return p == "height" ? oHeight : oWidth;
1306 return jQuery.curCSS( e, p );
1309 curCSS: function(elem, prop, force) {
1312 if (prop == 'opacity' && jQuery.browser.msie)
1313 return jQuery.attr(elem.style, 'opacity');
1315 if (prop == "float" || prop == "cssFloat")
1316 prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1318 if (!force && elem.style[prop]) {
1320 ret = elem.style[prop];
1322 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1324 if (prop == "cssFloat" || prop == "styleFloat")
1327 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1328 var cur = document.defaultView.getComputedStyle(elem, null);
1331 ret = cur.getPropertyValue(prop);
1332 else if ( prop == 'display' )
1335 jQuery.swap(elem, { display: 'block' }, function() {
1336 var c = document.defaultView.getComputedStyle(this, '');
1337 ret = c && c.getPropertyValue(prop) || '';
1340 } else if (elem.currentStyle) {
1342 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1343 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1350 clean: function(a) {
1352 for ( var i = 0, al = a.length; i < al; i++ ) {
1354 if ( typeof arg == "string" ) { // Convert html string into DOM nodes
1355 // Trim whitespace, otherwise indexOf won't work as expected
1356 var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6),
1357 div = document.createElement("div"), wrap = [0,"",""];
1359 if ( s.substring(0,4) == "<opt" ) // option or optgroup
1360 wrap = [1, "<select>", "</select>"];
1361 else if ( s6 == "<thead" || s6 == "<tbody" || s6 == "<tfoot" )
1362 wrap = [1, "<table>", "</table>"];
1363 else if ( s3 == "<tr" )
1364 wrap = [2, "<table><tbody>", "</tbody></table>"];
1365 else if ( s3 == "<td" || s3 == "<th" ) // <thead> matched above
1366 wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
1368 // Go to html and back, then peel off extra wrappers
1369 div.innerHTML = wrap[1] + s + wrap[2];
1370 while ( wrap[0]-- ) div = div.firstChild;
1372 // Remove IE's autoinserted <tbody> from table fragments
1373 if ( jQuery.browser.msie ) {
1375 // String was a <table>, *may* have spurious <tbody>
1376 if ( s6 == "<table" && s.indexOf("<tbody") < 0 )
1377 tb = div.firstChild && div.firstChild.childNodes;
1378 // String was a bare <thead> or <tfoot>
1379 else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1380 tb = div.childNodes;
1382 for ( var n = tb.length-1; n >= 0 ; --n )
1383 if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1384 tb[n].parentNode.removeChild(tb[n]);
1388 arg = div.childNodes;
1392 if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
1393 for ( var n = 0, argl = arg.length; n < argl; n++ ) // Handles Array, jQuery, DOM NodeList collections
1396 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
1402 attr: function(elem, name, value){
1405 "class": "className",
1406 "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1407 cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1408 innerHTML: "innerHTML",
1409 className: "className",
1411 disabled: "disabled",
1413 readonly: "readOnly",
1414 selected: "selected"
1417 // IE actually uses filters for opacity ... elem is actually elem.style
1418 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1419 // IE has trouble with opacity if it does not have layout
1420 // Force it by setting the zoom level
1423 // Set the alpha filter to set the opacity
1424 return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1425 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1427 } else if ( name == "opacity" && jQuery.browser.msie ) {
1428 return elem.filter ?
1429 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1432 // Mozilla doesn't play well with opacity 1
1433 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1436 // Certain attributes only work when accessed via the old DOM 0 way
1438 if ( value != undefined ) elem[fix[name]] = value;
1439 return elem[fix[name]];
1441 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1442 return elem.getAttributeNode(name).nodeValue;
1444 // IE elem.getAttribute passes even for style
1445 } else if ( elem.tagName ) {
1446 if ( value != undefined ) elem.setAttribute( name, value );
1447 return elem.getAttribute( name );
1450 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1451 if ( value != undefined ) elem[name] = value;
1457 * Remove the whitespace from the beginning and end of a string.
1459 * @example $.trim(" hello, how are you? ");
1460 * @result "hello, how are you?"
1464 * @param String str The string to trim.
1468 return t.replace(/^\s+|\s+$/g, "");
1471 makeArray: function( a ) {
1474 if ( a.constructor != Array ) {
1475 for ( var i = 0, al = a.length; i < al; i++ )
1483 inArray: function( b, a ) {
1484 for ( var i = 0, al = a.length; i < al; i++ )
1491 * Merge two arrays together, removing all duplicates. The final order
1492 * or the new array is: All the results from the first array, followed
1493 * by the unique results from the second array.
1495 * @example $.merge( [0,1,2], [2,3,4] )
1496 * @result [0,1,2,3,4]
1498 * @example $.merge( [3,2,1], [4,3,2] )
1503 * @param Array first The first array to merge.
1504 * @param Array second The second array to merge.
1507 merge: function(first, second) {
1508 var r = [].slice.call( first, 0 );
1510 // Now check for duplicates between the two arrays
1511 // and only add the unique items
1512 for ( var i = 0, sl = second.length; i < sl; i++ ) {
1513 // Check for duplicates
1514 if ( jQuery.inArray( second[i], r ) == -1 )
1515 // The item is unique, add it
1516 first.push( second[i] );
1523 * Filter items out of an array, by using a filter function.
1524 * The specified function will be passed two arguments: The
1525 * current array item and the index of the item in the array. The
1526 * function should return 'true' if you wish to keep the item in
1527 * the array, false if it should be removed.
1529 * @example $.grep( [0,1,2], function(i){
1536 * @param Array array The Array to find items in.
1537 * @param Function fn The function to process each item against.
1538 * @param Boolean inv Invert the selection - select the opposite of the function.
1541 grep: function(elems, fn, inv) {
1542 // If a string is passed in for the function, make a function
1543 // for it (a handy shortcut)
1544 if ( typeof fn == "string" )
1545 fn = new Function("a","i","return " + fn);
1549 // Go through the array, only saving the items
1550 // that pass the validator function
1551 for ( var i = 0, el = elems.length; i < el; i++ )
1552 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1553 result.push( elems[i] );
1559 * Translate all items in an array to another array of items.
1560 * The translation function that is provided to this method is
1561 * called for each item in the array and is passed one argument:
1562 * The item to be translated. The function can then return:
1563 * The translated value, 'null' (to remove the item), or
1564 * an array of values - which will be flattened into the full array.
1566 * @example $.map( [0,1,2], function(i){
1571 * @example $.map( [0,1,2], function(i){
1572 * return i > 0 ? i + 1 : null;
1576 * @example $.map( [0,1,2], function(i){
1577 * return [ i, i + 1 ];
1579 * @result [0, 1, 1, 2, 2, 3]
1583 * @param Array array The Array to translate.
1584 * @param Function fn The function to process each item against.
1587 map: function(elems, fn) {
1588 // If a string is passed in for the function, make a function
1589 // for it (a handy shortcut)
1590 if ( typeof fn == "string" )
1591 fn = new Function("a","return " + fn);
1593 var result = [], r = [];
1595 // Go through the array, translating each of the items to their
1596 // new value (or values).
1597 for ( var i = 0, el = elems.length; i < el; i++ ) {
1598 var val = fn(elems[i],i);
1600 if ( val !== null && val != undefined ) {
1601 if ( val.constructor != Array ) val = [val];
1602 result = result.concat( val );
1606 var r = [ result[0] ];
1608 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1609 for ( var j = 0; j < i; j++ )
1610 if ( result[i] == r[j] )
1613 r.push( result[i] );
1621 * Contains flags for the useragent, read from navigator.userAgent.
1622 * Available flags are: safari, opera, msie, mozilla
1623 * This property is available before the DOM is ready, therefore you can
1624 * use it to add ready events only for certain browsers.
1626 * There are situations where object detections is not reliable enough, in that
1627 * cases it makes sense to use browser detection. Simply try to avoid both!
1629 * A combination of browser and object detection yields quite reliable results.
1631 * @example $.browser.msie
1632 * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1634 * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1635 * @desc Alerts "this is safari!" only for safari browsers
1644 * Wheather the W3C compliant box model is being used.
1652 var b = navigator.userAgent.toLowerCase();
1654 // Figure out what browser is being used
1656 safari: /webkit/.test(b),
1657 opera: /opera/.test(b),
1658 msie: /msie/.test(b) && !/opera/.test(b),
1659 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1662 // Check to see if the W3C box model is being used
1663 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1669 * Append all of the matched elements to another, specified, set of elements.
1670 * This operation is, essentially, the reverse of doing a regular
1671 * $(A).append(B), in that instead of appending B to A, you're appending
1674 * @example $("p").appendTo("#foo");
1675 * @before <p>I would like to say: </p><div id="foo"></div>
1676 * @result <div id="foo"><p>I would like to say: </p></div>
1680 * @param String expr A jQuery expression of elements to match.
1681 * @cat DOM/Manipulation
1686 * Prepend all of the matched elements to another, specified, set of elements.
1687 * This operation is, essentially, the reverse of doing a regular
1688 * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1691 * @example $("p").prependTo("#foo");
1692 * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1693 * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1697 * @param String expr A jQuery expression of elements to match.
1698 * @cat DOM/Manipulation
1700 prependTo: "prepend",
1703 * Insert all of the matched elements before another, specified, set of elements.
1704 * This operation is, essentially, the reverse of doing a regular
1705 * $(A).before(B), in that instead of inserting B before A, you're inserting
1708 * @example $("p").insertBefore("#foo");
1709 * @before <div id="foo">Hello</div><p>I would like to say: </p>
1710 * @result <p>I would like to say: </p><div id="foo">Hello</div>
1712 * @name insertBefore
1714 * @param String expr A jQuery expression of elements to match.
1715 * @cat DOM/Manipulation
1717 insertBefore: "before",
1720 * Insert all of the matched elements after another, specified, set of elements.
1721 * This operation is, essentially, the reverse of doing a regular
1722 * $(A).after(B), in that instead of inserting B after A, you're inserting
1725 * @example $("p").insertAfter("#foo");
1726 * @before <p>I would like to say: </p><div id="foo">Hello</div>
1727 * @result <div id="foo">Hello</div><p>I would like to say: </p>
1731 * @param String expr A jQuery expression of elements to match.
1732 * @cat DOM/Manipulation
1734 insertAfter: "after"
1738 * Get the current CSS width of the first matched element.
1740 * @example $("p").width();
1741 * @before <p>This is just a test.</p>
1750 * Set the CSS width of every matched element. Be sure to include
1751 * the "px" (or other unit of measurement) after the number that you
1752 * specify, otherwise you might get strange results.
1754 * @example $("p").width("20px");
1755 * @before <p>This is just a test.</p>
1756 * @result <p style="width:20px;">This is just a test.</p>
1760 * @param String val Set the CSS property to the specified value.
1765 * Get the current CSS height of the first matched element.
1767 * @example $("p").height();
1768 * @before <p>This is just a test.</p>
1777 * Set the CSS height of every matched element. Be sure to include
1778 * the "px" (or other unit of measurement) after the number that you
1779 * specify, otherwise you might get strange results.
1781 * @example $("p").height("20px");
1782 * @before <p>This is just a test.</p>
1783 * @result <p style="height:20px;">This is just a test.</p>
1787 * @param String val Set the CSS property to the specified value.
1792 * Get the current CSS top of the first matched element.
1794 * @example $("p").top();
1795 * @before <p>This is just a test.</p>
1804 * Set the CSS top of every matched element. Be sure to include
1805 * the "px" (or other unit of measurement) after the number that you
1806 * specify, otherwise you might get strange results.
1808 * @example $("p").top("20px");
1809 * @before <p>This is just a test.</p>
1810 * @result <p style="top:20px;">This is just a test.</p>
1814 * @param String val Set the CSS property to the specified value.
1819 * Get the current CSS left of the first matched element.
1821 * @example $("p").left();
1822 * @before <p>This is just a test.</p>
1831 * Set the CSS left of every matched element. Be sure to include
1832 * the "px" (or other unit of measurement) after the number that you
1833 * specify, otherwise you might get strange results.
1835 * @example $("p").left("20px");
1836 * @before <p>This is just a test.</p>
1837 * @result <p style="left:20px;">This is just a test.</p>
1841 * @param String val Set the CSS property to the specified value.
1846 * Get the current CSS position of the first matched element.
1848 * @example $("p").position();
1849 * @before <p>This is just a test.</p>
1858 * Set the CSS position of every matched element.
1860 * @example $("p").position("relative");
1861 * @before <p>This is just a test.</p>
1862 * @result <p style="position:relative;">This is just a test.</p>
1866 * @param String val Set the CSS property to the specified value.
1871 * Get the current CSS float of the first matched element.
1873 * @example $("p").float();
1874 * @before <p>This is just a test.</p>
1883 * Set the CSS float of every matched element.
1885 * @example $("p").float("left");
1886 * @before <p>This is just a test.</p>
1887 * @result <p style="float:left;">This is just a test.</p>
1891 * @param String val Set the CSS property to the specified value.
1896 * Get the current CSS overflow of the first matched element.
1898 * @example $("p").overflow();
1899 * @before <p>This is just a test.</p>
1908 * Set the CSS overflow of every matched element.
1910 * @example $("p").overflow("auto");
1911 * @before <p>This is just a test.</p>
1912 * @result <p style="overflow:auto;">This is just a test.</p>
1916 * @param String val Set the CSS property to the specified value.
1921 * Get the current CSS color of the first matched element.
1923 * @example $("p").color();
1924 * @before <p>This is just a test.</p>
1933 * Set the CSS color of every matched element.
1935 * @example $("p").color("blue");
1936 * @before <p>This is just a test.</p>
1937 * @result <p style="color:blue;">This is just a test.</p>
1941 * @param String val Set the CSS property to the specified value.
1946 * Get the current CSS background of the first matched element.
1948 * @example $("p").background();
1949 * @before <p style="background:blue;">This is just a test.</p>
1958 * Set the CSS background of every matched element.
1960 * @example $("p").background("blue");
1961 * @before <p>This is just a test.</p>
1962 * @result <p style="background:blue;">This is just a test.</p>
1966 * @param String val Set the CSS property to the specified value.
1970 css: "width,height,top,left,position,float,overflow,color,background".split(","),
1973 * Reduce the set of matched elements to a single element.
1974 * The position of the element in the set of matched elements
1975 * starts at 0 and goes to length - 1.
1977 * @example $("p").eq(1)
1978 * @before <p>This is just a test.</p><p>So is this</p>
1979 * @result [ <p>So is this</p> ]
1983 * @param Number pos The index of the element that you wish to limit to.
1988 * Reduce the set of matched elements to all elements before a given position.
1989 * The position of the element in the set of matched elements
1990 * starts at 0 and goes to length - 1.
1992 * @example $("p").lt(1)
1993 * @before <p>This is just a test.</p><p>So is this</p>
1994 * @result [ <p>This is just a test.</p> ]
1998 * @param Number pos Reduce the set to all elements below this position.
2003 * Reduce the set of matched elements to all elements after a given position.
2004 * The position of the element in the set of matched elements
2005 * starts at 0 and goes to length - 1.
2007 * @example $("p").gt(0)
2008 * @before <p>This is just a test.</p><p>So is this</p>
2009 * @result [ <p>So is this</p> ]
2013 * @param Number pos Reduce the set to all elements after this position.
2018 * Filter the set of elements to those that contain the specified text.
2020 * @example $("p").contains("test")
2021 * @before <p>This is just a test.</p><p>So is this</p>
2022 * @result [ <p>This is just a test.</p> ]
2026 * @param String str The string that will be contained within the text of an element.
2027 * @cat DOM/Traversing
2030 filter: [ "eq", "lt", "gt", "contains" ],
2034 * Get the current value of the first matched element.
2036 * @example $("input").val();
2037 * @before <input type="text" value="some text"/>
2038 * @result "some text"
2042 * @cat DOM/Attributes
2046 * Set the value of every matched element.
2048 * @example $("input").val("test");
2049 * @before <input type="text" value="some text"/>
2050 * @result <input type="text" value="test"/>
2054 * @param String val Set the property to the specified value.
2055 * @cat DOM/Attributes
2060 * Get the html contents of the first matched element.
2061 * This property is not available on XML documents.
2063 * @example $("div").html();
2064 * @before <div><input/></div>
2069 * @cat DOM/Attributes
2073 * Set the html contents of every matched element.
2074 * This property is not available on XML documents.
2076 * @example $("div").html("<b>new stuff</b>");
2077 * @before <div><input/></div>
2078 * @result <div><b>new stuff</b></div>
2082 * @param String val Set the html contents to the specified value.
2083 * @cat DOM/Attributes
2088 * Get the current id of the first matched element.
2090 * @example $("input").id();
2091 * @before <input type="text" id="test" value="some text"/>
2096 * @cat DOM/Attributes
2100 * Set the id of every matched element.
2102 * @example $("input").id("newid");
2103 * @before <input type="text" id="test" value="some text"/>
2104 * @result <input type="text" id="newid" value="some text"/>
2108 * @param String val Set the property to the specified value.
2109 * @cat DOM/Attributes
2114 * Get the current title of the first matched element.
2116 * @example $("img").title();
2117 * @before <img src="test.jpg" title="my image"/>
2118 * @result "my image"
2122 * @cat DOM/Attributes
2126 * Set the title of every matched element.
2128 * @example $("img").title("new title");
2129 * @before <img src="test.jpg" title="my image"/>
2130 * @result <img src="test.jpg" title="new image"/>
2134 * @param String val Set the property to the specified value.
2135 * @cat DOM/Attributes
2140 * Get the current name of the first matched element.
2142 * @example $("input").name();
2143 * @before <input type="text" name="username"/>
2144 * @result "username"
2148 * @cat DOM/Attributes
2152 * Set the name of every matched element.
2154 * @example $("input").name("user");
2155 * @before <input type="text" name="username"/>
2156 * @result <input type="text" name="user"/>
2160 * @param String val Set the property to the specified value.
2161 * @cat DOM/Attributes
2166 * Get the current href of the first matched element.
2168 * @example $("a").href();
2169 * @before <a href="test.html">my link</a>
2170 * @result "test.html"
2174 * @cat DOM/Attributes
2178 * Set the href of every matched element.
2180 * @example $("a").href("test2.html");
2181 * @before <a href="test.html">my link</a>
2182 * @result <a href="test2.html">my link</a>
2186 * @param String val Set the property to the specified value.
2187 * @cat DOM/Attributes
2192 * Get the current src of the first matched element.
2194 * @example $("img").src();
2195 * @before <img src="test.jpg" title="my image"/>
2196 * @result "test.jpg"
2200 * @cat DOM/Attributes
2204 * Set the src of every matched element.
2206 * @example $("img").src("test2.jpg");
2207 * @before <img src="test.jpg" title="my image"/>
2208 * @result <img src="test2.jpg" title="my image"/>
2212 * @param String val Set the property to the specified value.
2213 * @cat DOM/Attributes
2218 * Get the current rel of the first matched element.
2220 * @example $("a").rel();
2221 * @before <a href="test.html" rel="nofollow">my link</a>
2222 * @result "nofollow"
2226 * @cat DOM/Attributes
2230 * Set the rel of every matched element.
2232 * @example $("a").rel("nofollow");
2233 * @before <a href="test.html">my link</a>
2234 * @result <a href="test.html" rel="nofollow">my link</a>
2238 * @param String val Set the property to the specified value.
2239 * @cat DOM/Attributes
2246 * Get a set of elements containing the unique parents of the matched
2249 * @example $("p").parent()
2250 * @before <div><p>Hello</p><p>Hello</p></div>
2251 * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2255 * @cat DOM/Traversing
2259 * Get a set of elements containing the unique parents of the matched
2260 * set of elements, and filtered by an expression.
2262 * @example $("p").parent(".selected")
2263 * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2264 * @result [ <div class="selected"><p>Hello Again</p></div> ]
2268 * @param String expr An expression to filter the parents with
2269 * @cat DOM/Traversing
2271 parent: "a.parentNode",
2274 * Get a set of elements containing the unique ancestors of the matched
2275 * set of elements (except for the root element).
2277 * @example $("span").parents()
2278 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2279 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2283 * @cat DOM/Traversing
2287 * Get a set of elements containing the unique ancestors of the matched
2288 * set of elements, and filtered by an expression.
2290 * @example $("span").parents("p")
2291 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2292 * @result [ <p><span>Hello</span></p> ]
2296 * @param String expr An expression to filter the ancestors with
2297 * @cat DOM/Traversing
2299 parents: jQuery.parents,
2302 * Get a set of elements containing the unique next siblings of each of the
2303 * matched set of elements.
2305 * It only returns the very next sibling, not all next siblings.
2307 * @example $("p").next()
2308 * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2309 * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2313 * @cat DOM/Traversing
2317 * Get a set of elements containing the unique next siblings of each of the
2318 * matched set of elements, and filtered by an expression.
2320 * It only returns the very next sibling, not all next siblings.
2322 * @example $("p").next(".selected")
2323 * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2324 * @result [ <p class="selected">Hello Again</p> ]
2328 * @param String expr An expression to filter the next Elements with
2329 * @cat DOM/Traversing
2331 next: "jQuery.nth(a,1,'nextSibling')",
2334 * Get a set of elements containing the unique previous siblings of each of the
2335 * matched set of elements.
2337 * It only returns the immediately previous sibling, not all previous siblings.
2339 * @example $("p").prev()
2340 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2341 * @result [ <div><span>Hello Again</span></div> ]
2345 * @cat DOM/Traversing
2349 * Get a set of elements containing the unique previous siblings of each of the
2350 * matched set of elements, and filtered by an expression.
2352 * It only returns the immediately previous sibling, not all previous siblings.
2354 * @example $("p").prev(".selected")
2355 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2356 * @result [ <div><span>Hello</span></div> ]
2360 * @param String expr An expression to filter the previous Elements with
2361 * @cat DOM/Traversing
2363 prev: "jQuery.nth(a,1,'previousSibling')",
2366 * Get a set of elements containing all of the unique siblings of each of the
2367 * matched set of elements.
2369 * @example $("div").siblings()
2370 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2371 * @result [ <p>Hello</p>, <p>And Again</p> ]
2375 * @cat DOM/Traversing
2379 * Get a set of elements containing all of the unique siblings of each of the
2380 * matched set of elements, and filtered by an expression.
2382 * @example $("div").siblings(".selected")
2383 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2384 * @result [ <p class="selected">Hello Again</p> ]
2388 * @param String expr An expression to filter the sibling Elements with
2389 * @cat DOM/Traversing
2391 siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
2394 * Get a set of elements containing all of the unique children of each of the
2395 * matched set of elements.
2397 * @example $("div").children()
2398 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2399 * @result [ <span>Hello Again</span> ]
2403 * @cat DOM/Traversing
2407 * Get a set of elements containing all of the unique children of each of the
2408 * matched set of elements, and filtered by an expression.
2410 * @example $("div").children(".selected")
2411 * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2412 * @result [ <p class="selected">Hello Again</p> ]
2416 * @param String expr An expression to filter the child Elements with
2417 * @cat DOM/Traversing
2419 children: "jQuery.sibling(a.firstChild)"
2425 * Remove an attribute from each of the matched elements.
2427 * @example $("input").removeAttr("disabled")
2428 * @before <input disabled="disabled"/>
2433 * @param String name The name of the attribute to remove.
2436 removeAttr: function( key ) {
2437 jQuery.attr( this, key, "" );
2438 this.removeAttribute( key );
2442 * Displays each of the set of matched elements if they are hidden.
2444 * @example $("p").show()
2445 * @before <p style="display: none">Hello</p>
2446 * @result [ <p style="display: block">Hello</p> ]
2453 this.style.display = this.oldblock ? this.oldblock : "";
2454 if ( jQuery.css(this,"display") == "none" )
2455 this.style.display = "block";
2459 * Hides each of the set of matched elements if they are shown.
2461 * @example $("p").hide()
2462 * @before <p>Hello</p>
2463 * @result [ <p style="display: none">Hello</p> ]
2465 * var pass = true, div = $("div");
2466 * div.hide().each(function(){
2467 * if ( this.style.display != "none" ) pass = false;
2469 * ok( pass, "Hide" );
2476 this.oldblock = this.oldblock || jQuery.css(this,"display");
2477 if ( this.oldblock == "none" )
2478 this.oldblock = "block";
2479 this.style.display = "none";
2483 * Toggles each of the set of matched elements. If they are shown,
2484 * toggle makes them hidden. If they are hidden, toggle
2487 * @example $("p").toggle()
2488 * @before <p>Hello</p><p style="display: none">Hello Again</p>
2489 * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2496 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2500 * Adds the specified class to each of the set of matched elements.
2502 * @example $("p").addClass("selected")
2503 * @before <p>Hello</p>
2504 * @result [ <p class="selected">Hello</p> ]
2508 * @param String class A CSS class to add to the elements
2511 addClass: function(c){
2512 jQuery.className.add(this,c);
2516 * Removes all or the specified class from the set of matched elements.
2518 * @example $("p").removeClass()
2519 * @before <p class="selected">Hello</p>
2520 * @result [ <p>Hello</p> ]
2522 * @example $("p").removeClass("selected")
2523 * @before <p class="selected first">Hello</p>
2524 * @result [ <p class="first">Hello</p> ]
2528 * @param String class (optional) A CSS class to remove from the elements
2531 removeClass: function(c){
2532 jQuery.className.remove(this,c);
2536 * Adds the specified class if it is not present, removes it if it is
2539 * @example $("p").toggleClass("selected")
2540 * @before <p>Hello</p><p class="selected">Hello Again</p>
2541 * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2545 * @param String class A CSS class with which to toggle the elements
2548 toggleClass: function( c ){
2549 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2553 * Removes all matched elements from the DOM. This does NOT remove them from the
2554 * jQuery object, allowing you to use the matched elements further.
2556 * @example $("p").remove();
2557 * @before <p>Hello</p> how are <p>you?</p>
2562 * @cat DOM/Manipulation
2566 * Removes only elements (out of the list of matched elements) that match
2567 * the specified jQuery expression. This does NOT remove them from the
2568 * jQuery object, allowing you to use the matched elements further.
2570 * @example $("p").remove(".hello");
2571 * @before <p class="hello">Hello</p> how are <p>you?</p>
2572 * @result how are <p>you?</p>
2576 * @param String expr A jQuery expression to filter elements by.
2577 * @cat DOM/Manipulation
2579 remove: function(a){
2580 if ( !a || jQuery.filter( a, [this] ).r )
2581 this.parentNode.removeChild( this );
2585 * Removes all child nodes from the set of matched elements.
2587 * @example $("p").empty()
2588 * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2589 * @result [ <p></p> ]
2593 * @cat DOM/Manipulation
2596 while ( this.firstChild )
2597 this.removeChild( this.firstChild );