2 * jQuery @VERSION - New Wave Javascript
\r
4 * Copyright (c) 2006 John Resig (jquery.com)
\r
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
\r
6 * and GPL (GPL-LICENSE.txt) licenses.
\r
12 // Global undefined variable
\r
13 window.undefined = window.undefined;
\r
16 * Create a new jQuery Object
\r
23 var jQuery = function(a,c) {
\r
25 // Shortcut for document ready
\r
26 if ( a && typeof a == "function" && jQuery.fn.ready && !a.nodeType && a[0] == undefined ) // Safari reports typeof on DOM NodeLists as a function
\r
27 return jQuery(document).ready(a);
\r
29 // Make sure that a selection was provided
\r
32 // Watch for when a jQuery object is passed as the selector
\r
34 return jQuery( jQuery.merge( a, [] ) );
\r
36 // Watch for when a jQuery object is passed at the context
\r
37 if ( c && c.jquery )
\r
38 return jQuery( c ).find(a);
\r
40 // If the context is global, return a new object
\r
41 if ( window == this )
\r
42 return new jQuery(a,c);
\r
44 // Handle HTML strings
\r
45 if ( typeof a == "string" ) {
\r
46 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
\r
47 if ( m ) a = jQuery.clean( [ m[1] ] );
\r
50 // Watch for when an array is passed in
\r
51 this.set( a.constructor == Array || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType ?
\r
52 // Assume that it is an array of DOM Elements
\r
53 jQuery.merge( a, [] ) :
\r
55 // Find the matching elements and save them for later
\r
56 jQuery.find( a, c ) );
\r
58 // See if an extra function was provided
\r
59 var fn = arguments[ arguments.length - 1 ];
\r
61 // If so, execute it in context
\r
62 if ( fn && typeof fn == "function" )
\r
68 // Map over the $ in case of overwrite
\r
69 if ( typeof $ != "undefined" )
\r
72 // Map the jQuery namespace to the '$' one
\r
76 * This function accepts a string containing a CSS or
\r
77 * basic XPath selector which is then used to match a set of elements.
\r
79 * The core functionality of jQuery centers around this function.
\r
80 * Everything in jQuery is based upon this, or uses this in some way.
\r
81 * The most basic use of this function is to pass in an expression
\r
82 * (usually consisting of CSS or XPath), which then finds all matching
\r
85 * By default, $() looks for DOM elements within the context of the
\r
86 * current HTML document.
\r
88 * @example $("div > p")
\r
89 * @desc This finds all p elements that are children of a div element.
\r
90 * @before <p>one</p> <div><p>two</p></div> <p>three</p>
\r
91 * @result [ <p>two</p> ]
\r
93 * @example $("input:radio", document.forms[0])
\r
94 * @desc Searches for all inputs of type radio within the first form in the document
\r
96 * @example $("div", xml.responseXML)
\r
97 * @desc This finds all div elements within the specified XML document.
\r
100 * @param String expr An expression to search with
\r
101 * @param Element context (optional) A DOM Element, or Document, representing the base context.
\r
105 * @see $(Element<Array>)
\r
109 * This function accepts a string of raw HTML.
\r
111 * The HTML string is different from the traditional selectors in that
\r
112 * it creates the DOM elements representing that HTML string, on the fly,
\r
113 * to be (assumedly) inserted into the document later.
\r
115 * @example $("<div><p>Hello</p></div>").appendTo("#body")
\r
116 * @desc Creates a div element (and all of its contents) dynamically,
\r
117 * and appends it to the element with the ID of body. Internally, an
\r
118 * element is created and it's innerHTML property set to the given markup.
\r
119 * It is therefore both quite flexible and limited.
\r
122 * @param String html A string of HTML to create on the fly.
\r
128 * Wrap jQuery functionality around a specific DOM Element.
\r
129 * This function also accepts XML Documents and Window objects
\r
130 * as valid arguments (even though they are not DOM Elements).
\r
132 * @example $(document).find("div > p")
\r
133 * @before <p>one</p> <div><p>two</p></div> <p>three</p>
\r
134 * @result [ <p>two</p> ]
\r
136 * @example $(document.body).background( "black" );
\r
137 * @desc Sets the background color of the page to black.
\r
140 * @param Element elem A DOM element to be encapsulated by a jQuery object.
\r
146 * Wrap jQuery functionality around a set of DOM Elements.
\r
148 * @example $( myForm.elements ).hide()
\r
149 * @desc Hides all the input elements within a form
\r
152 * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
\r
158 * A shorthand for $(document).ready(), allowing you to bind a function
\r
159 * to be executed when the DOM document has finished loading. This function
\r
160 * behaves just like $(document).ready(), in that it should be used to wrap
\r
161 * all of the other $() operations on your page. While this function is,
\r
162 * technically, chainable - there really isn't much use for chaining against it.
\r
163 * You can have as many $(document).ready events on your page as you like.
\r
165 * See ready(Function) for details about the ready event.
\r
167 * @example $(function(){
\r
168 * // Document is ready
\r
170 * @desc Executes the function when the DOM is ready to be used.
\r
173 * @param Function fn The function to execute when the DOM is ready.
\r
179 * A means of creating a cloned copy of a jQuery object. This function
\r
180 * copies the set of matched elements from one jQuery object and creates
\r
181 * another, new, jQuery object containing the same elements.
\r
183 * @example var div = $("div");
\r
184 * $( div ).find("p");
\r
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).
\r
188 * @param jQuery obj The jQuery object to be cloned.
\r
193 jQuery.fn = jQuery.prototype = {
\r
195 * The current version of jQuery.
\r
203 jquery: "@VERSION",
\r
206 * The number of elements currently matched.
\r
208 * @example $("img").length;
\r
209 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
\r
219 * The number of elements currently matched.
\r
221 * @example $("img").size();
\r
222 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
\r
230 return this.length;
\r
234 * Access all matched elements. This serves as a backwards-compatible
\r
235 * way of accessing all matched elements (other than the jQuery object
\r
236 * itself, which is, in fact, an array of elements).
\r
238 * @example $("img").get();
\r
239 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
\r
240 * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
\r
243 * @type Array<Element>
\r
248 * Access a single matched element. num is used to access the
\r
249 * Nth element matched.
\r
251 * @example $("img").get(1);
\r
252 * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
\r
253 * @result [ <img src="test1.jpg"/> ]
\r
257 * @param Number num Access the element in the Nth position.
\r
260 get: function( num ) {
\r
261 return num == undefined ?
\r
263 // Return a 'clean' array
\r
264 jQuery.merge( this, [] ) :
\r
266 // Return just the object
\r
271 * Set the jQuery object to an array of elements.
\r
273 * @example $("img").set([ document.body ]);
\r
274 * @result $("img").set() == [ document.body ]
\r
279 * @param Elements elems An array of elements
\r
282 set: function( array ) {
\r
283 // Use a tricky hack to make the jQuery object
\r
284 // look and feel like an array
\r
286 [].push.apply( this, array );
\r
291 * Execute a function within the context of every matched element.
\r
292 * This means that every time the passed-in function is executed
\r
293 * (which is once for every element matched) the 'this' keyword
\r
294 * points to the specific element.
\r
296 * Additionally, the function, when executed, is passed a single
\r
297 * argument representing the position of the element in the matched
\r
300 * @example $("img").each(function(i){
\r
301 * this.src = "test" + i + ".jpg";
\r
303 * @before <img/> <img/>
\r
304 * @result <img src="test0.jpg"/> <img src="test1.jpg"/>
\r
305 * @desc Iterates over two images and sets their src property
\r
309 * @param Function fn A function to execute
\r
312 each: function( fn, args ) {
\r
313 return jQuery.each( this, fn, args );
\r
317 * Searches every matched element for the object and returns
\r
318 * the index of the element, if found, starting with zero.
\r
319 * Returns -1 if the object wasn't found.
\r
321 * @example $("*").index(document.getElementById('foobar'))
\r
322 * @before <div id="foobar"></div><b></b><span id="foo"></span>
\r
325 * @example $("*").index(document.getElementById('foo'))
\r
326 * @before <div id="foobar"></div><b></b><span id="foo"></span>
\r
329 * @example $("*").index(document.getElementById('bar'))
\r
330 * @before <div id="foobar"></div><b></b><span id="foo"></span>
\r
335 * @param Object obj Object to search for
\r
338 index: function( obj ) {
\r
340 this.each(function(i){
\r
341 if ( this == obj ) pos = i;
\r
347 * Access a property on the first matched element.
\r
348 * This method makes it easy to retrieve a property value
\r
349 * from the first matched element.
\r
351 * @example $("img").attr("src");
\r
352 * @before <img src="test.jpg"/>
\r
357 * @param String name The name of the property to access.
\r
362 * Set a hash of key/value object properties to all matched elements.
\r
363 * This serves as the best way to set a large number of properties
\r
364 * on all matched elements.
\r
366 * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
\r
368 * @result <img src="test.jpg" alt="Test Image"/>
\r
372 * @param Hash prop A set of key/value pairs to set as object properties.
\r
377 * Set a single property to a value, on all matched elements.
\r
379 * Note that you can't set the name property of input elements in IE.
\r
380 * Use $(html) or $().append(html) or $().html(html) to create elements
\r
381 * on the fly including the name property.
\r
383 * @example $("img").attr("src","test.jpg");
\r
385 * @result <img src="test.jpg"/>
\r
389 * @param String key The name of the property to set.
\r
390 * @param Object value The value to set the property to.
\r
393 attr: function( key, value, type ) {
\r
394 // Check to see if we're setting style values
\r
395 return typeof key != "string" || value != undefined ?
\r
396 this.each(function(){
\r
397 // See if we're setting a hash of styles
\r
398 if ( value == undefined )
\r
399 // Set all the styles
\r
400 for ( var prop in key )
\r
402 type ? this.style : this,
\r
406 // See if we're setting a single key/value style
\r
409 type ? this.style : this,
\r
414 // Look for the case where we're accessing a style value
\r
415 jQuery[ type || "attr" ]( this[0], key );
\r
419 * Access a style property on the first matched element.
\r
420 * This method makes it easy to retrieve a style property value
\r
421 * from the first matched element.
\r
423 * @example $("p").css("color");
\r
424 * @before <p style="color:red;">Test Paragraph.</p>
\r
426 * @desc Retrieves the color style of the first paragraph
\r
428 * @example $("p").css("fontWeight");
\r
429 * @before <p style="font-weight: bold;">Test Paragraph.</p>
\r
431 * @desc Retrieves the font-weight style of the first paragraph.
\r
432 * Note that for all style properties with a dash (like 'font-weight'), you have to
\r
433 * write it in camelCase. In other words: Every time you have a '-' in a
\r
434 * property, remove it and replace the next character with an uppercase
\r
435 * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
\r
436 * borderStyle, borderBottomWidth etc.
\r
440 * @param String name The name of the property to access.
\r
445 * Set a hash of key/value style properties to all matched elements.
\r
446 * This serves as the best way to set a large number of style properties
\r
447 * on all matched elements.
\r
449 * @example $("p").css({ color: "red", background: "blue" });
\r
450 * @before <p>Test Paragraph.</p>
\r
451 * @result <p style="color:red; background:blue;">Test Paragraph.</p>
\r
455 * @param Hash prop A set of key/value pairs to set as style properties.
\r
460 * Set a single style property to a value, on all matched elements.
\r
462 * @example $("p").css("color","red");
\r
463 * @before <p>Test Paragraph.</p>
\r
464 * @result <p style="color:red;">Test Paragraph.</p>
\r
465 * @desc Changes the color of all paragraphs to red
\r
469 * @param String key The name of the property to set.
\r
470 * @param Object value The value to set the property to.
\r
473 css: function( key, value ) {
\r
474 return this.attr( key, value, "curCSS" );
\r
478 * Retrieve the text contents of all matched elements. The result is
\r
479 * a string that contains the combined text contents of all matched
\r
480 * elements. This method works on both HTML and XML documents.
\r
482 * @example $("p").text();
\r
483 * @before <p>Test Paragraph.</p>
\r
484 * @result Test Paragraph.
\r
490 text: function(e) {
\r
493 for ( var j = 0; j < e.length; j++ ) {
\r
494 var r = e[j].childNodes;
\r
495 for ( var i = 0; i < r.length; i++ )
\r
496 if ( r[i].nodeType != 8 )
\r
497 t += r[i].nodeType != 1 ?
\r
498 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
\r
504 * Wrap all matched elements with a structure of other elements.
\r
505 * This wrapping process is most useful for injecting additional
\r
506 * stucture into a document, without ruining the original semantic
\r
507 * qualities of a document.
\r
509 * This works by going through the first element
\r
510 * provided (which is generated, on the fly, from the provided HTML)
\r
511 * and finds the deepest ancestor element within its
\r
512 * structure - it is that element that will en-wrap everything else.
\r
514 * This does not work with elements that contain text. Any necessary text
\r
515 * must be added after the wrapping is done.
\r
517 * @example $("p").wrap("<div class='wrap'></div>");
\r
518 * @before <p>Test Paragraph.</p>
\r
519 * @result <div class='wrap'><p>Test Paragraph.</p></div>
\r
523 * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
\r
524 * @cat DOM/Manipulation
\r
528 * Wrap all matched elements with a structure of other elements.
\r
529 * This wrapping process is most useful for injecting additional
\r
530 * stucture into a document, without ruining the original semantic
\r
531 * qualities of a document.
\r
533 * This works by going through the first element
\r
534 * provided and finding the deepest ancestor element within its
\r
535 * structure - it is that element that will en-wrap everything else.
\r
537 * This does not work with elements that contain text. Any necessary text
\r
538 * must be added after the wrapping is done.
\r
540 * @example $("p").wrap( document.getElementById('content') );
\r
541 * @before <p>Test Paragraph.</p><div id="content"></div>
\r
542 * @result <div id="content"><p>Test Paragraph.</p></div>
\r
546 * @param Element elem A DOM element that will be wrapped.
\r
547 * @cat DOM/Manipulation
\r
550 // The elements to wrap the target around
\r
551 var a = jQuery.clean(arguments);
\r
553 // Wrap each of the matched elements individually
\r
554 return this.each(function(){
\r
555 // Clone the structure that we're using to wrap
\r
556 var b = a[0].cloneNode(true);
\r
558 // Insert it before the element to be wrapped
\r
559 this.parentNode.insertBefore( b, this );
\r
561 // Find the deepest point in the wrap structure
\r
562 while ( b.firstChild )
\r
565 // Move the matched element to within the wrap structure
\r
566 b.appendChild( this );
\r
571 * Append any number of elements to the inside of every matched elements,
\r
572 * generated from the provided HTML.
\r
573 * This operation is similar to doing an appendChild to all the
\r
574 * specified elements, adding them into the document.
\r
576 * @example $("p").append("<b>Hello</b>");
\r
577 * @before <p>I would like to say: </p>
\r
578 * @result <p>I would like to say: <b>Hello</b></p>
\r
582 * @param String html A string of HTML, that will be created on the fly and appended to the target.
\r
583 * @cat DOM/Manipulation
\r
587 * Append an element to the inside of all matched elements.
\r
588 * This operation is similar to doing an appendChild to all the
\r
589 * specified elements, adding them into the document.
\r
591 * @example $("p").append( $("#foo")[0] );
\r
592 * @before <p>I would like to say: </p><b id="foo">Hello</b>
\r
593 * @result <p>I would like to say: <b id="foo">Hello</b></p>
\r
597 * @param Element elem A DOM element that will be appended.
\r
598 * @cat DOM/Manipulation
\r
602 * Append any number of elements to the inside of all matched elements.
\r
603 * This operation is similar to doing an appendChild to all the
\r
604 * specified elements, adding them into the document.
\r
606 * @example $("p").append( $("b") );
\r
607 * @before <p>I would like to say: </p><b>Hello</b>
\r
608 * @result <p>I would like to say: <b>Hello</b></p>
\r
612 * @param Array<Element> elems An array of elements, all of which will be appended.
\r
613 * @cat DOM/Manipulation
\r
615 append: function() {
\r
616 return this.domManip(arguments, true, 1, function(a){
\r
617 this.appendChild( a );
\r
622 * Prepend any number of elements to the inside of every matched elements,
\r
623 * generated from the provided HTML.
\r
624 * This operation is the best way to insert dynamically created elements
\r
625 * inside, at the beginning, of all the matched element.
\r
627 * @example $("p").prepend("<b>Hello</b>");
\r
628 * @before <p>I would like to say: </p>
\r
629 * @result <p><b>Hello</b>I would like to say: </p>
\r
633 * @param String html A string of HTML, that will be created on the fly and appended to the target.
\r
634 * @cat DOM/Manipulation
\r
638 * Prepend an element to the inside of all matched elements.
\r
639 * This operation is the best way to insert an element inside, at the
\r
640 * beginning, of all the matched element.
\r
642 * @example $("p").prepend( $("#foo")[0] );
\r
643 * @before <p>I would like to say: </p><b id="foo">Hello</b>
\r
644 * @result <p><b id="foo">Hello</b>I would like to say: </p>
\r
648 * @param Element elem A DOM element that will be appended.
\r
649 * @cat DOM/Manipulation
\r
653 * Prepend any number of elements to the inside of all matched elements.
\r
654 * This operation is the best way to insert a set of elements inside, at the
\r
655 * beginning, of all the matched element.
\r
657 * @example $("p").prepend( $("b") );
\r
658 * @before <p>I would like to say: </p><b>Hello</b>
\r
659 * @result <p><b>Hello</b>I would like to say: </p>
\r
663 * @param Array<Element> elems An array of elements, all of which will be appended.
\r
664 * @cat DOM/Manipulation
\r
666 prepend: function() {
\r
667 return this.domManip(arguments, true, -1, function(a){
\r
668 this.insertBefore( a, this.firstChild );
\r
673 * Insert any number of dynamically generated elements before each of the
\r
674 * matched elements.
\r
676 * @example $("p").before("<b>Hello</b>");
\r
677 * @before <p>I would like to say: </p>
\r
678 * @result <b>Hello</b><p>I would like to say: </p>
\r
682 * @param String html A string of HTML, that will be created on the fly and appended to the target.
\r
683 * @cat DOM/Manipulation
\r
687 * Insert an element before each of the matched elements.
\r
689 * @example $("p").before( $("#foo")[0] );
\r
690 * @before <p>I would like to say: </p><b id="foo">Hello</b>
\r
691 * @result <b id="foo">Hello</b><p>I would like to say: </p>
\r
695 * @param Element elem A DOM element that will be appended.
\r
696 * @cat DOM/Manipulation
\r
700 * Insert any number of elements before each of the matched elements.
\r
702 * @example $("p").before( $("b") );
\r
703 * @before <p>I would like to say: </p><b>Hello</b>
\r
704 * @result <b>Hello</b><p>I would like to say: </p>
\r
708 * @param Array<Element> elems An array of elements, all of which will be appended.
\r
709 * @cat DOM/Manipulation
\r
711 before: function() {
\r
712 return this.domManip(arguments, false, 1, function(a){
\r
713 this.parentNode.insertBefore( a, this );
\r
718 * Insert any number of dynamically generated elements after each of the
\r
719 * matched elements.
\r
721 * @example $("p").after("<b>Hello</b>");
\r
722 * @before <p>I would like to say: </p>
\r
723 * @result <p>I would like to say: </p><b>Hello</b>
\r
727 * @param String html A string of HTML, that will be created on the fly and appended to the target.
\r
728 * @cat DOM/Manipulation
\r
732 * Insert an element after each of the matched elements.
\r
734 * @example $("p").after( $("#foo")[0] );
\r
735 * @before <b id="foo">Hello</b><p>I would like to say: </p>
\r
736 * @result <p>I would like to say: </p><b id="foo">Hello</b>
\r
740 * @param Element elem A DOM element that will be appended.
\r
741 * @cat DOM/Manipulation
\r
745 * Insert any number of elements after each of the matched elements.
\r
747 * @example $("p").after( $("b") );
\r
748 * @before <b>Hello</b><p>I would like to say: </p>
\r
749 * @result <p>I would like to say: </p><b>Hello</b>
\r
753 * @param Array<Element> elems An array of elements, all of which will be appended.
\r
754 * @cat DOM/Manipulation
\r
756 after: function() {
\r
757 return this.domManip(arguments, false, -1, function(a){
\r
758 this.parentNode.insertBefore( a, this.nextSibling );
\r
763 * End the most recent 'destructive' operation, reverting the list of matched elements
\r
764 * back to its previous state. After an end operation, the list of matched elements will
\r
765 * revert to the last state of matched elements.
\r
767 * @example $("p").find("span").end();
\r
768 * @before <p><span>Hello</span>, how are you?</p>
\r
769 * @result $("p").find("span").end() == [ <p>...</p> ]
\r
773 * @cat DOM/Traversing
\r
776 if( !(this.stack && this.stack.length) )
\r
778 return this.set( this.stack.pop() );
\r
782 * Searches for all elements that match the specified expression.
\r
783 * This method is the optimal way of finding additional descendant
\r
784 * elements with which to process.
\r
786 * All searching is done using a jQuery expression. The expression can be
\r
787 * written using CSS 1-3 Selector syntax, or basic XPath.
\r
789 * @example $("p").find("span");
\r
790 * @before <p><span>Hello</span>, how are you?</p>
\r
791 * @result $("p").find("span") == [ <span>Hello</span> ]
\r
795 * @param String expr An expression to search with.
\r
796 * @cat DOM/Traversing
\r
798 find: function(t) {
\r
799 return this.pushStack( jQuery.map( this, function(a){
\r
800 return jQuery.find(t,a);
\r
805 * Create cloned copies of all matched DOM Elements. This does
\r
806 * not create a cloned copy of this particular jQuery object,
\r
807 * instead it creates duplicate copies of all DOM Elements.
\r
808 * This is useful for moving copies of the elements to another
\r
809 * location in the DOM.
\r
811 * @example $("b").clone().prependTo("p");
\r
812 * @before <b>Hello</b><p>, how are you?</p>
\r
813 * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
\r
817 * @cat DOM/Manipulation
\r
819 clone: function(deep) {
\r
820 return this.pushStack( jQuery.map( this, function(a){
\r
821 return a.cloneNode( deep != undefined ? deep : true );
\r
826 * Removes all elements from the set of matched elements that do not
\r
827 * match the specified expression. This method is used to narrow down
\r
828 * the results of a search.
\r
830 * All searching is done using a jQuery expression. The expression
\r
831 * can be written using CSS 1-3 Selector syntax, or basic XPath.
\r
833 * @example $("p").filter(".selected")
\r
834 * @before <p class="selected">Hello</p><p>How are you?</p>
\r
835 * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
\r
839 * @param String expr An expression to search with.
\r
840 * @cat DOM/Traversing
\r
844 * Removes all elements from the set of matched elements that do not
\r
845 * match at least one of the expressions passed to the function. This
\r
846 * method is used when you want to filter the set of matched elements
\r
847 * through more than one expression.
\r
849 * Elements will be retained in the jQuery object if they match at
\r
850 * least one of the expressions passed.
\r
852 * @example $("p").filter([".selected", ":first"])
\r
853 * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
\r
854 * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
\r
858 * @param Array<String> exprs A set of expressions to evaluate against
\r
859 * @cat DOM/Traversing
\r
861 filter: function(t) {
\r
862 return this.pushStack(
\r
863 t.constructor == Array &&
\r
864 jQuery.map(this,function(a){
\r
865 for ( var i = 0; i < t.length; i++ )
\r
866 if ( jQuery.filter(t[i],[a]).r.length )
\r
871 t.constructor == Boolean &&
\r
872 ( t ? this.get() : [] ) ||
\r
874 typeof t == "function" &&
\r
875 jQuery.grep( this, t ) ||
\r
877 jQuery.filter(t,this).r, arguments );
\r
881 * Removes the specified Element from the set of matched elements. This
\r
882 * method is used to remove a single Element from a jQuery object.
\r
884 * @example $("p").not( document.getElementById("selected") )
\r
885 * @before <p>Hello</p><p id="selected">Hello Again</p>
\r
886 * @result [ <p>Hello</p> ]
\r
890 * @param Element el An element to remove from the set
\r
891 * @cat DOM/Traversing
\r
895 * Removes elements matching the specified expression from the set
\r
896 * of matched elements. This method is used to remove one or more
\r
897 * elements from a jQuery object.
\r
899 * @example $("p").not("#selected")
\r
900 * @before <p>Hello</p><p id="selected">Hello Again</p>
\r
901 * @result [ <p>Hello</p> ]
\r
905 * @param String expr An expression with which to remove matching elements
\r
906 * @cat DOM/Traversing
\r
909 return this.pushStack( typeof t == "string" ?
\r
910 jQuery.filter(t,this,false).r :
\r
911 jQuery.grep(this,function(a){ return a != t; }), arguments );
\r
915 * Adds the elements matched by the expression to the jQuery object. This
\r
916 * can be used to concatenate the result sets of two expressions.
\r
918 * @example $("p").add("span")
\r
919 * @before <p>Hello</p><p><span>Hello Again</span></p>
\r
920 * @result [ <p>Hello</p>, <span>Hello Again</span> ]
\r
924 * @param String expr An expression whose matched elements are added
\r
925 * @cat DOM/Traversing
\r
929 * Adds each of the Elements in the array to the set of matched elements.
\r
930 * This is used to add a set of Elements to a jQuery object.
\r
932 * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
\r
933 * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
\r
934 * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
\r
938 * @param Array<Element> els An array of Elements to add
\r
939 * @cat DOM/Traversing
\r
943 * Adds a single Element to the set of matched elements. This is used to
\r
944 * add a single Element to a jQuery object.
\r
946 * @example $("p").add( document.getElementById("a") )
\r
947 * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
\r
948 * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
\r
952 * @param Element el An Element to add
\r
953 * @cat DOM/Traversing
\r
956 return this.pushStack( jQuery.merge( this, typeof t == "string" ?
\r
957 jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
\r
961 * Checks the current selection against an expression and returns true,
\r
962 * if at least one element of the selection fits the given expression.
\r
963 * Does return false, if no element fits or the expression is not valid.
\r
965 * @example $("input[@type='checkbox']").parent().is("form")
\r
966 * @before <form><input type="checkbox" /></form>
\r
968 * @desc Returns true, because the parent of the input is a form element
\r
970 * @example $("input[@type='checkbox']").parent().is("form")
\r
971 * @before <form><p><input type="checkbox" /></p></form>
\r
973 * @desc Returns false, because the parent of the input is a p element
\r
975 * @example $("form").is(null)
\r
976 * @before <form></form>
\r
978 * @desc An invalid expression always returns false.
\r
982 * @param String expr The expression with which to filter
\r
983 * @cat DOM/Traversing
\r
985 is: function(expr) {
\r
986 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
\r
992 * @param Array args
\r
993 * @param Boolean table Insert TBODY in TABLEs if one is not found.
\r
994 * @param Number dir If dir<0, process args in reverse order.
\r
995 * @param Function fn The function doing the DOM manipulation.
\r
999 domManip: function(args, table, dir, fn){
\r
1000 var clone = this.length > 1;
\r
1001 var a = jQuery.clean(args);
\r
1005 return this.each(function(){
\r
1008 if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
\r
1009 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
\r
1011 for ( var i=0; i < a.length; i++ )
\r
1012 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
\r
1023 * @param Array args
\r
1027 pushStack: function(a,args) {
\r
1028 var fn = args && args.length > 1 && args[args.length-1];
\r
1029 var fn2 = args && args.length > 2 && args[args.length-2];
\r
1031 if ( fn && fn.constructor != Function ) fn = null;
\r
1032 if ( fn2 && fn2.constructor != Function ) fn2 = null;
\r
1035 if ( !this.stack ) this.stack = [];
\r
1036 this.stack.push( this.get() );
\r
1039 var old = this.get();
\r
1042 if ( fn2 && a.length || !fn2 )
\r
1043 this.each( fn2 || fn ).set( old );
\r
1045 this.set( old ).each( fn );
\r
1053 * Extends the jQuery object itself. Can be used to add functions into
\r
1054 * the jQuery namespace and to add plugin methods (plugins).
\r
1056 * @example jQuery.fn.extend({
\r
1057 * check: function() {
\r
1058 * return this.each(function() { this.checked = true; });
\r
1060 * uncheck: function() {
\r
1061 * return this.each(function() { this.checked = false; });
\r
1064 * $("input[@type=checkbox]").check();
\r
1065 * $("input[@type=radio]").uncheck();
\r
1066 * @desc Adds two plugin methods.
\r
1068 * @example jQuery.extend({
\r
1069 * min: function(a, b) { return a < b ? a : b; },
\r
1070 * max: function(a, b) { return a > b ? a : b; }
\r
1072 * @desc Adds two functions into the jQuery namespace
\r
1075 * @param Object prop The object that will be merged into the jQuery object
\r
1081 * Extend one object with one or more others, returning the original,
\r
1082 * modified, object. This is a great utility for simple inheritance.
\r
1084 * @example var settings = { validate: false, limit: 5, name: "foo" };
\r
1085 * var options = { validate: true, name: "bar" };
\r
1086 * jQuery.extend(settings, options);
\r
1087 * @result settings == { validate: true, limit: 5, name: "bar" }
\r
1088 * @desc Merge settings and options, modifying settings
\r
1090 * @example var defaults = { validate: false, limit: 5, name: "foo" };
\r
1091 * var options = { validate: true, name: "bar" };
\r
1092 * var settings = jQuery.extend({}, defaults, options);
\r
1093 * @result settings == { validate: true, limit: 5, name: "bar" }
\r
1094 * @desc Merge defaults and options, without modifying the defaults
\r
1097 * @param Object target The object to extend
\r
1098 * @param Object prop1 The object that will be merged into the first.
\r
1099 * @param Object propN (optional) More objects to merge into the first
\r
1103 jQuery.extend = jQuery.fn.extend = function() {
\r
1104 // copy reference to target object
\r
1105 var target = arguments[0],
\r
1108 // extend jQuery itself if only one argument is passed
\r
1109 if ( arguments.length == 1 ) {
\r
1114 while (prop = arguments[a++])
\r
1115 // Extend the base object
\r
1116 for ( var i in prop ) target[i] = prop[i];
\r
1118 // Return the modified object
\r
1130 jQuery.initDone = true;
\r
1132 jQuery.each( jQuery.macros.axis, function(i,n){
\r
1133 jQuery.fn[ i ] = function(a) {
\r
1134 var ret = jQuery.map(this,n);
\r
1135 if ( a && typeof a == "string" )
\r
1136 ret = jQuery.filter(a,ret).r;
\r
1137 return this.pushStack( ret, arguments );
\r
1141 jQuery.each( jQuery.macros.to, function(i,n){
\r
1142 jQuery.fn[ i ] = function(){
\r
1143 var a = arguments;
\r
1144 return this.each(function(){
\r
1145 for ( var j = 0; j < a.length; j++ )
\r
1146 jQuery(a[j])[n]( this );
\r
1151 jQuery.each( jQuery.macros.each, function(i,n){
\r
1152 jQuery.fn[ i ] = function() {
\r
1153 return this.each( n, arguments );
\r
1157 jQuery.each( jQuery.macros.filter, function(i,n){
\r
1158 jQuery.fn[ n ] = function(num,fn) {
\r
1159 return this.filter( ":" + n + "(" + num + ")", fn );
\r
1163 jQuery.each( jQuery.macros.attr, function(i,n){
\r
1165 jQuery.fn[ i ] = function(h) {
\r
1166 return h == undefined ?
\r
1167 this.length ? this[0][n] : null :
\r
1168 this.attr( n, h );
\r
1172 jQuery.each( jQuery.macros.css, function(i,n){
\r
1173 jQuery.fn[ n ] = function(h) {
\r
1174 return h == undefined ?
\r
1175 ( this.length ? jQuery.css( this[0], n ) : null ) :
\r
1183 * A generic iterator function, which can be used to seemlessly
\r
1184 * iterate over both objects and arrays. This function is not the same
\r
1185 * as $().each() - which is used to iterate, exclusively, over a jQuery
\r
1186 * object. This function can be used to iterate over anything.
\r
1188 * @example $.each( [0,1,2], function(i){
\r
1189 * alert( "Item #" + i + ": " + this );
\r
1191 * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
\r
1193 * @example $.each( { name: "John", lang: "JS" }, function(i){
\r
1194 * alert( "Name: " + i + ", Value: " + this );
\r
1196 * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
\r
1199 * @param Object obj The object, or array, to iterate over.
\r
1200 * @param Function fn The function that will be executed on every object.
\r
1204 // args is for internal usage only
\r
1205 each: function( obj, fn, args ) {
\r
1206 if ( obj.length == undefined )
\r
1207 for ( var i in obj )
\r
1208 fn.apply( obj[i], args || [i, obj[i]] );
\r
1210 for ( var i = 0; i < obj.length; i++ )
\r
1211 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
\r
1216 add: function(o,c){
\r
1217 if (jQuery.className.has(o,c)) return;
\r
1218 o.className += ( o.className ? " " : "" ) + c;
\r
1220 remove: function(o,c){
\r
1224 var classes = o.className.split(" ");
\r
1225 for(var i=0; i<classes.length; i++) {
\r
1226 if(classes[i] == c) {
\r
1227 classes.splice(i, 1);
\r
1231 o.className = classes.join(' ');
\r
1234 has: function(e,a) {
\r
1235 if ( e.className != undefined )
\r
1237 return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
\r
1242 * Swap in/out style options.
\r
1245 swap: function(e,o,f) {
\r
1246 for ( var i in o ) {
\r
1247 e.style["old"+i] = e.style[i];
\r
1248 e.style[i] = o[i];
\r
1251 for ( var i in o )
\r
1252 e.style[i] = e.style["old"+i];
\r
1255 css: function(e,p) {
\r
1256 if ( p == "height" || p == "width" ) {
\r
1257 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
\r
1259 for ( var i=0; i<d.length; i++ ) {
\r
1260 old["padding" + d[i]] = 0;
\r
1261 old["border" + d[i] + "Width"] = 0;
\r
1264 jQuery.swap( e, old, function() {
\r
1265 if (jQuery.css(e,"display") != "none") {
\r
1266 oHeight = e.offsetHeight;
\r
1267 oWidth = e.offsetWidth;
\r
1269 e = jQuery(e.cloneNode(true))
\r
1270 .find(":radio").removeAttr("checked").end()
\r
1272 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
\r
1273 }).appendTo(e.parentNode)[0];
\r
1275 var parPos = jQuery.css(e.parentNode,"position");
\r
1276 if ( parPos == "" || parPos == "static" )
\r
1277 e.parentNode.style.position = "relative";
\r
1279 oHeight = e.clientHeight;
\r
1280 oWidth = e.clientWidth;
\r
1282 if ( parPos == "" || parPos == "static" )
\r
1283 e.parentNode.style.position = "static";
\r
1285 e.parentNode.removeChild(e);
\r
1289 return p == "height" ? oHeight : oWidth;
\r
1292 return jQuery.curCSS( e, p );
\r
1295 curCSS: function(elem, prop, force) {
\r
1298 if (prop == 'opacity' && jQuery.browser.msie)
\r
1299 return jQuery.attr(elem.style, 'opacity');
\r
1301 if (prop == "float" || prop == "cssFloat")
\r
1302 prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
\r
1304 if (!force && elem.style[prop]) {
\r
1306 ret = elem.style[prop];
\r
1308 } else if (document.defaultView && document.defaultView.getComputedStyle) {
\r
1310 if (prop == "cssFloat" || prop == "styleFloat")
\r
1313 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
\r
1314 var cur = document.defaultView.getComputedStyle(elem, null);
\r
1317 ret = cur.getPropertyValue(prop);
\r
1318 else if ( prop == 'display' )
\r
1321 jQuery.swap(elem, { display: 'block' }, function() {
\r
1322 var c = document.defaultView.getComputedStyle(this, '');
\r
1323 ret = c && c.getPropertyValue(prop) || '';
\r
1326 } else if (elem.currentStyle) {
\r
1328 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
\r
1329 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
\r
1336 clean: function(a) {
\r
1338 for ( var i = 0; i < a.length; i++ ) {
\r
1340 if ( typeof arg == "string" ) { // Convert html string into DOM nodes
\r
1341 // Trim whitespace, otherwise indexOf won't work as expected
\r
1342 var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6),
\r
1343 div = document.createElement("div"), wrap = [0,"",""];
\r
1345 if ( s.substring(0,4) == "<opt" ) // option or optgroup
\r
1346 wrap = [1, "<select>", "</select>"];
\r
1347 else if ( s6 == "<thead" || s6 == "<tbody" || s6 == "<tfoot" )
\r
1348 wrap = [1, "<table>", "</table>"];
\r
1349 else if ( s3 == "<tr" )
\r
1350 wrap = [2, "<table><tbody>", "</tbody></table>"];
\r
1351 else if ( s3 == "<td" || s3 == "<th" ) // <thead> matched above
\r
1352 wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
\r
1354 // Go to html and back, then peel off extra wrappers
\r
1355 div.innerHTML = wrap[1] + s + wrap[2];
\r
1356 while ( wrap[0]-- ) div = div.firstChild;
\r
1358 // Remove IE's autoinserted <tbody> from table fragments
\r
1359 if ( jQuery.browser.msie ) {
\r
1361 // String was a <table>, *may* have spurious <tbody>
\r
1362 if ( s6 == "<table" && s.indexOf("<tbody") < 0 )
\r
1363 tb = div.firstChild && div.firstChild.childNodes;
\r
1364 // String was a bare <thead> or <tfoot>
\r
1365 else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
\r
1366 tb = div.childNodes;
\r
1368 for ( var n = tb.length-1; n >= 0 ; --n )
\r
1369 if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
\r
1370 tb[n].parentNode.removeChild(tb[n]);
\r
1374 arg = div.childNodes;
\r
1378 if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
\r
1379 for ( var n = 0; n < arg.length; n++ ) // Handles Array, jQuery, DOM NodeList collections
\r
1382 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
\r
1389 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
\r
1390 "#": "a.getAttribute('id')==m[2]",
\r
1392 // Position Checks
\r
1398 last: "i==r.length-1",
\r
1403 "nth-child": "jQuery.sibling(a,m[3]).cur",
\r
1404 "first-child": "jQuery.sibling(a,0).cur",
\r
1405 "last-child": "jQuery.sibling(a,0).last",
\r
1406 "only-child": "jQuery.sibling(a).length==1",
\r
1409 parent: "a.childNodes.length",
\r
1410 empty: "!a.childNodes.length",
\r
1413 contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
\r
1416 visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
\r
1417 hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
\r
1419 // Form attributes
\r
1420 enabled: "!a.disabled",
\r
1421 disabled: "a.disabled",
\r
1422 checked: "a.checked",
\r
1423 selected: "a.selected",
\r
1426 text: "a.type=='text'",
\r
1427 radio: "a.type=='radio'",
\r
1428 checkbox: "a.type=='checkbox'",
\r
1429 file: "a.type=='file'",
\r
1430 password: "a.type=='password'",
\r
1431 submit: "a.type=='submit'",
\r
1432 image: "a.type=='image'",
\r
1433 reset: "a.type=='reset'",
\r
1434 button: "a.type=='button'",
\r
1435 input: "/input|select|textarea|button/i.test(a.nodeName)"
\r
1437 ".": "jQuery.className.has(a,m[2])",
\r
1441 "^=": "z && !z.indexOf(m[4])",
\r
1442 "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
\r
1443 "*=": "z && z.indexOf(m[4])>=0",
\r
1446 "[": "jQuery.find(m[2],a).length"
\r
1450 "\\.\\.|/\\.\\.", "a.parentNode",
\r
1451 ">|/", "jQuery.sibling(a.firstChild)",
\r
1452 "\\+", "jQuery.sibling(a).next",
\r
1454 var s = jQuery.sibling(a);
\r
1455 return s.n >= 0 ? s.slice(s.n+1) : [];
\r
1461 * @type Array<Element>
\r
1465 find: function( t, context ) {
\r
1466 // Make sure that the context is a DOM Element
\r
1467 if ( context && context.nodeType == undefined )
\r
1470 // Set the correct context (if none is provided)
\r
1471 context = context || document;
\r
1473 if ( typeof t != "string" ) return [t];
\r
1475 if ( !t.indexOf("//") ) {
\r
1476 context = context.documentElement;
\r
1477 t = t.substr(2,t.length);
\r
1478 } else if ( !t.indexOf("/") ) {
\r
1479 context = context.documentElement;
\r
1480 t = t.substr(1,t.length);
\r
1481 // FIX Assume the root element is right :(
\r
1482 if ( t.indexOf("/") >= 1 )
\r
1483 t = t.substr(t.indexOf("/"),t.length);
\r
1486 var ret = [context];
\r
1490 while ( t.length > 0 && last != t ) {
\r
1494 t = jQuery.trim(t).replace( /^\/\//i, "" );
\r
1496 var foundToken = false;
\r
1498 for ( var i = 0; i < jQuery.token.length; i += 2 ) {
\r
1499 if ( foundToken ) continue;
\r
1501 var re = new RegExp("^(" + jQuery.token[i] + ")");
\r
1502 var m = re.exec(t);
\r
1505 r = ret = jQuery.map( ret, jQuery.token[i+1] );
\r
1506 t = jQuery.trim( t.replace( re, "" ) );
\r
1507 foundToken = true;
\r
1511 if ( !foundToken ) {
\r
1512 if ( !t.indexOf(",") || !t.indexOf("|") ) {
\r
1513 if ( ret[0] == context ) ret.shift();
\r
1514 done = jQuery.merge( done, ret );
\r
1515 r = ret = [context];
\r
1516 t = " " + t.substr(1,t.length);
\r
1518 var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
\r
1519 var m = re2.exec(t);
\r
1521 if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
\r
1522 // Optimization for HTML document case
\r
1523 var oid = ret[ret.length-1].getElementById(m[2]);
\r
1524 r = ret = oid ? [oid] : [];
\r
1525 t = t.replace( re2, "" );
\r
1527 if ( !m[2] || m[1] == "." || m[1] == "#" ) m[2] = "*";
\r
1529 for ( var i = 0; i < ret.length; i++ )
\r
1530 r = jQuery.merge( r,
\r
1532 jQuery.getAll(ret[i]) :
\r
1533 ret[i].getElementsByTagName(m[2])
\r
1541 var val = jQuery.filter(t,r);
\r
1543 t = jQuery.trim(val.t);
\r
1547 if ( ret && ret[0] == context ) ret.shift();
\r
1548 done = jQuery.merge( done, ret );
\r
1553 getAll: function(o,r) {
\r
1555 var s = o.childNodes;
\r
1556 for ( var i = 0; i < s.length; i++ )
\r
1557 if ( s[i].nodeType == 1 ) {
\r
1559 jQuery.getAll( s[i], r );
\r
1564 attr: function(elem, name, value){
\r
1567 "class": "className",
\r
1568 "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
\r
1569 cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
\r
1570 innerHTML: "innerHTML",
\r
1571 className: "className",
\r
1573 disabled: "disabled",
\r
1574 checked: "checked",
\r
1575 readonly: "readOnly",
\r
1576 selected: "selected"
\r
1579 // IE actually uses filters for opacity ... elem is actually elem.style
\r
1580 if (name == "opacity" && jQuery.browser.msie && value != undefined) {
\r
1581 // IE has trouble with opacity if it does not have layout
\r
1582 // Would prefer to check element.hasLayout first but don't have access to the element here
\r
1583 elem['zoom'] = 1;
\r
1584 if (value == 1) // Remove filter to avoid more IE weirdness
\r
1585 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
\r
1587 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
\r
1588 } else if (name == "opacity" && jQuery.browser.msie) {
\r
1589 return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
\r
1592 // Mozilla doesn't play well with opacity 1
\r
1593 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
\r
1595 if ( fix[name] ) {
\r
1596 if ( value != undefined ) elem[fix[name]] = value;
\r
1597 return elem[fix[name]];
\r
1598 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
\r
1599 return elem.getAttributeNode(name).nodeValue;
\r
1600 } else if ( elem.tagName ) { // IE elem.getAttribute passes even for style
\r
1601 if ( value != undefined ) elem.setAttribute( name, value );
\r
1602 return elem.getAttribute( name );
\r
1604 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
\r
1605 if ( value != undefined ) elem[name] = value;
\r
1606 return elem[name];
\r
1610 // The regular expressions that power the parsing engine
\r
1612 // Match: [@value='test'], [@foo]
\r
1613 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
\r
1615 // Match: [div], [div p]
\r
1616 "(\\[)\s*(.*?)\s*\\]",
\r
1618 // Match: :contains('foo')
\r
1619 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
\r
1621 // Match: :even, :last-chlid
\r
1625 filter: function(t,r,not) {
\r
1626 // Figure out if we're doing regular, or inverse, filtering
\r
1627 var g = not !== false ? jQuery.grep :
\r
1628 function(a,f) {return jQuery.grep(a,f,true);};
\r
1630 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
\r
1632 var p = jQuery.parse;
\r
1634 for ( var i = 0; i < p.length; i++ ) {
\r
1636 // Look for, and replace, string-like sequences
\r
1637 // and finally build a regexp out of it
\r
1638 var re = new RegExp(
\r
1639 "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
\r
1641 var m = re.exec( t );
\r
1644 // Re-organize the first match
\r
1646 m = ["",m[1], m[3], m[2], m[5]];
\r
1648 // Remove what we just matched
\r
1649 t = t.replace( re, "" );
\r
1655 // :not() is a special case that can be optimized by
\r
1656 // keeping it out of the expression list
\r
1657 if ( m[1] == ":" && m[2] == "not" )
\r
1658 r = jQuery.filter(m[3],r,false).r;
\r
1660 // Otherwise, find the expression to execute
\r
1662 var f = jQuery.expr[m[1]];
\r
1663 if ( typeof f != "string" )
\r
1664 f = jQuery.expr[m[1]][m[2]];
\r
1666 // Build a custom macro to enclose it
\r
1667 eval("f = function(a,i){" +
\r
1668 ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
\r
1669 "return " + f + "}");
\r
1671 // Execute it against the current filter
\r
1676 // Return an array of filtered elements (r)
\r
1677 // and the modified expression string (t)
\r
1678 return { r: r, t: t };
\r
1682 * Remove the whitespace from the beginning and end of a string.
\r
1684 * @example $.trim(" hello, how are you? ");
\r
1685 * @result "hello, how are you?"
\r
1689 * @param String str The string to trim.
\r
1692 trim: function(t){
\r
1693 return t.replace(/^\s+|\s+$/g, "");
\r
1697 * All ancestors of a given element.
\r
1701 * @type Array<Element>
\r
1702 * @param Element elem The element to find the ancestors of.
\r
1703 * @cat DOM/Traversing
\r
1705 parents: function( elem ){
\r
1707 var cur = elem.parentNode;
\r
1708 while ( cur && cur != document ) {
\r
1709 matched.push( cur );
\r
1710 cur = cur.parentNode;
\r
1716 * All elements on a specified axis.
\r
1721 * @param Element elem The element to find all the siblings of (including itself).
\r
1722 * @cat DOM/Traversing
\r
1724 sibling: function(elem, pos, not) {
\r
1728 var siblings = elem.parentNode.childNodes;
\r
1729 for ( var i = 0; i < siblings.length; i++ ) {
\r
1730 if ( not === true && siblings[i] == elem ) continue;
\r
1732 if ( siblings[i].nodeType == 1 )
\r
1733 elems.push( siblings[i] );
\r
1734 if ( siblings[i] == elem )
\r
1735 elems.n = elems.length - 1;
\r
1739 return jQuery.extend( elems, {
\r
1740 last: elems.n == elems.length - 1,
\r
1741 cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
\r
1742 prev: elems[elems.n - 1],
\r
1743 next: elems[elems.n + 1]
\r
1748 * Merge two arrays together, removing all duplicates. The final order
\r
1749 * or the new array is: All the results from the first array, followed
\r
1750 * by the unique results from the second array.
\r
1752 * @example $.merge( [0,1,2], [2,3,4] )
\r
1753 * @result [0,1,2,3,4]
\r
1755 * @example $.merge( [3,2,1], [4,3,2] )
\r
1756 * @result [3,2,1,4]
\r
1760 * @param Array first The first array to merge.
\r
1761 * @param Array second The second array to merge.
\r
1764 merge: function(first, second) {
\r
1767 // Move b over to the new array (this helps to avoid
\r
1768 // StaticNodeList instances)
\r
1769 for ( var k = 0; k < first.length; k++ )
\r
1770 result[k] = first[k];
\r
1772 // Now check for duplicates between a and b
\r
1773 // and only add the unique items
\r
1775 for ( var i = 0; i < second.length; i++ ) {
\r
1776 for ( var j = 0; j < first.length; j++ )
\r
1777 if ( second[i] == first[j] )
\r
1778 continue DupCheck;
\r
1779 // The item is unique, add it
\r
1780 result.push( second[i] );
\r
1787 * Filter items out of an array, by using a filter function.
\r
1788 * The specified function will be passed two arguments: The
\r
1789 * current array item and the index of the item in the array. The
\r
1790 * function should return 'true' if you wish to keep the item in
\r
1791 * the array, false if it should be removed.
\r
1793 * @example $.grep( [0,1,2], function(i){
\r
1800 * @param Array array The Array to find items in.
\r
1801 * @param Function fn The function to process each item against.
\r
1802 * @param Boolean inv Invert the selection - select the opposite of the function.
\r
1805 grep: function(elems, fn, inv) {
\r
1806 // If a string is passed in for the function, make a function
\r
1807 // for it (a handy shortcut)
\r
1808 if ( typeof fn == "string" )
\r
1809 fn = new Function("a","i","return " + fn);
\r
1813 // Go through the array, only saving the items
\r
1814 // that pass the validator function
\r
1815 for ( var i = 0; i < elems.length; i++ )
\r
1816 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
\r
1817 result.push( elems[i] );
\r
1823 * Translate all items in an array to another array of items.
\r
1824 * The translation function that is provided to this method is
\r
1825 * called for each item in the array and is passed one argument:
\r
1826 * The item to be translated. The function can then return:
\r
1827 * The translated value, 'null' (to remove the item), or
\r
1828 * an array of values - which will be flattened into the full array.
\r
1830 * @example $.map( [0,1,2], function(i){
\r
1833 * @result [4, 5, 6]
\r
1835 * @example $.map( [0,1,2], function(i){
\r
1836 * return i > 0 ? i + 1 : null;
\r
1840 * @example $.map( [0,1,2], function(i){
\r
1841 * return [ i, i + 1 ];
\r
1843 * @result [0, 1, 1, 2, 2, 3]
\r
1847 * @param Array array The Array to translate.
\r
1848 * @param Function fn The function to process each item against.
\r
1851 map: function(elems, fn) {
\r
1852 // If a string is passed in for the function, make a function
\r
1853 // for it (a handy shortcut)
\r
1854 if ( typeof fn == "string" )
\r
1855 fn = new Function("a","return " + fn);
\r
1859 // Go through the array, translating each of the items to their
\r
1860 // new value (or values).
\r
1861 for ( var i = 0; i < elems.length; i++ ) {
\r
1862 var val = fn(elems[i],i);
\r
1864 if ( val !== null && val != undefined ) {
\r
1865 if ( val.constructor != Array ) val = [val];
\r
1866 result = jQuery.merge( result, val );
\r
1874 * A number of helper functions used for managing events.
\r
1875 * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
\r
1879 // Bind an event to an element
\r
1880 // Original by Dean Edwards
\r
1881 add: function(element, type, handler) {
\r
1882 // For whatever reason, IE has trouble passing the window object
\r
1883 // around, causing it to be cloned in the process
\r
1884 if ( jQuery.browser.msie && element.setInterval != undefined )
\r
1887 // Make sure that the function being executed has a unique ID
\r
1888 if ( !handler.guid )
\r
1889 handler.guid = this.guid++;
\r
1891 // Init the element's event structure
\r
1892 if (!element.events)
\r
1893 element.events = {};
\r
1895 // Get the current list of functions bound to this event
\r
1896 var handlers = element.events[type];
\r
1898 // If it hasn't been initialized yet
\r
1900 // Init the event handler queue
\r
1901 handlers = element.events[type] = {};
\r
1903 // Remember an existing handler, if it's already there
\r
1904 if (element["on" + type])
\r
1905 handlers[0] = element["on" + type];
\r
1908 // Add the function to the element's handler list
\r
1909 handlers[handler.guid] = handler;
\r
1911 // And bind the global event handler to the element
\r
1912 element["on" + type] = this.handle;
\r
1914 // Remember the function in a global list (for triggering)
\r
1915 if (!this.global[type])
\r
1916 this.global[type] = [];
\r
1917 this.global[type].push( element );
\r
1923 // Detach an event or set of events from an element
\r
1924 remove: function(element, type, handler) {
\r
1925 if (element.events)
\r
1926 if (type && element.events[type])
\r
1928 delete element.events[type][handler.guid];
\r
1930 for ( var i in element.events[type] )
\r
1931 delete element.events[type][i];
\r
1933 for ( var j in element.events )
\r
1934 this.remove( element, j );
\r
1937 trigger: function(type,data,element) {
\r
1938 // Clone the incoming data, if any
\r
1939 data = $.merge([], data || []);
\r
1941 // Handle a global trigger
\r
1943 var g = this.global[type];
\r
1945 for ( var i = 0; i < g.length; i++ )
\r
1946 this.trigger( type, data, g[i] );
\r
1948 // Handle triggering a single element
\r
1949 } else if ( element["on" + type] ) {
\r
1950 // Pass along a fake event
\r
1951 data.unshift( this.fix({ type: type, target: element }) );
\r
1953 // Trigger the event
\r
1954 element["on" + type].apply( element, data );
\r
1958 handle: function(event) {
\r
1959 if ( typeof jQuery == "undefined" ) return false;
\r
1961 event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data
\r
1963 var returnValue = true;
\r
1965 var c = this.events[event.type];
\r
1967 var args = [].slice.call( arguments, 1 );
\r
1968 args.unshift( event );
\r
1970 for ( var j in c ) {
\r
1971 if ( c[j].apply( this, args ) === false ) {
\r
1972 event.preventDefault();
\r
1973 event.stopPropagation();
\r
1974 returnValue = false;
\r
1978 // Clean up added properties in IE to prevent memory leak
\r
1979 if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = null;
\r
1981 return returnValue;
\r
1984 fix: function(event) {
\r
1985 // fix target property, if available
\r
1986 if(event.srcElement)
\r
1987 event.target = event.srcElement;
\r
1989 // calculate pageX/Y if missing
\r
1990 if(typeof event.pageX == "undefined") {
\r
1991 var e = document.documentElement, b = document.body;
\r
1992 event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
\r
1993 event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
\r
1996 // check if target is a textnode (only for safari)
\r
1997 if(jQuery.browser.safari && event.target.nodeType == 3) {
\r
1998 // target is readonly, clone the event object
\r
1999 event = jQuery.extend({}, event);
\r
2000 // get parentnode from textnode
\r
2001 event.target = event.target.parentNode;
\r
2004 // fix preventDefault and stopPropagation
\r
2005 if (!event.preventDefault) {
\r
2006 event.preventDefault = function() {
\r
2007 this.returnValue = false;
\r
2011 if (!event.stopPropagation) {
\r
2012 event.stopPropagation = function() {
\r
2013 this.cancelBubble = true;
\r
2023 * Contains flags for the useragent, read from navigator.userAgent.
\r
2024 * Available flags are: safari, opera, msie, mozilla
\r
2025 * This property is available before the DOM is ready, therefore you can
\r
2026 * use it to add ready events only for certain browsers.
\r
2028 * There are situations where object detections is not reliable enough, in that
\r
2029 * cases it makes sense to use browser detection. Simply try to avoid both!
\r
2031 * A combination of browser and object detection yields quite reliable results.
\r
2033 * @example $.browser.msie
\r
2034 * @desc Returns true if the current useragent is some version of microsoft's internet explorer
\r
2036 * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
\r
2037 * @desc Alerts "this is safari!" only for safari browsers
\r
2046 * Wheather the W3C compliant box model is being used.
\r
2049 * @name $.boxModel
\r
2054 var b = navigator.userAgent.toLowerCase();
\r
2056 // Figure out what browser is being used
\r
2057 jQuery.browser = {
\r
2058 safari: /webkit/.test(b),
\r
2059 opera: /opera/.test(b),
\r
2060 msie: /msie/.test(b) && !/opera/.test(b),
\r
2061 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
\r
2064 // Check to see if the W3C box model is being used
\r
2065 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
\r
2071 * Append all of the matched elements to another, specified, set of elements.
\r
2072 * This operation is, essentially, the reverse of doing a regular
\r
2073 * $(A).append(B), in that instead of appending B to A, you're appending
\r
2076 * @example $("p").appendTo("#foo");
\r
2077 * @before <p>I would like to say: </p><div id="foo"></div>
\r
2078 * @result <div id="foo"><p>I would like to say: </p></div>
\r
2082 * @param String expr A jQuery expression of elements to match.
\r
2083 * @cat DOM/Manipulation
\r
2085 appendTo: "append",
\r
2088 * Prepend all of the matched elements to another, specified, set of elements.
\r
2089 * This operation is, essentially, the reverse of doing a regular
\r
2090 * $(A).prepend(B), in that instead of prepending B to A, you're prepending
\r
2093 * @example $("p").prependTo("#foo");
\r
2094 * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
\r
2095 * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
\r
2099 * @param String expr A jQuery expression of elements to match.
\r
2100 * @cat DOM/Manipulation
\r
2102 prependTo: "prepend",
\r
2105 * Insert all of the matched elements before another, specified, set of elements.
\r
2106 * This operation is, essentially, the reverse of doing a regular
\r
2107 * $(A).before(B), in that instead of inserting B before A, you're inserting
\r
2110 * @example $("p").insertBefore("#foo");
\r
2111 * @before <div id="foo">Hello</div><p>I would like to say: </p>
\r
2112 * @result <p>I would like to say: </p><div id="foo">Hello</div>
\r
2114 * @name insertBefore
\r
2116 * @param String expr A jQuery expression of elements to match.
\r
2117 * @cat DOM/Manipulation
\r
2119 insertBefore: "before",
\r
2122 * Insert all of the matched elements after another, specified, set of elements.
\r
2123 * This operation is, essentially, the reverse of doing a regular
\r
2124 * $(A).after(B), in that instead of inserting B after A, you're inserting
\r
2127 * @example $("p").insertAfter("#foo");
\r
2128 * @before <p>I would like to say: </p><div id="foo">Hello</div>
\r
2129 * @result <div id="foo">Hello</div><p>I would like to say: </p>
\r
2131 * @name insertAfter
\r
2133 * @param String expr A jQuery expression of elements to match.
\r
2134 * @cat DOM/Manipulation
\r
2136 insertAfter: "after"
\r
2140 * Get the current CSS width of the first matched element.
\r
2142 * @example $("p").width();
\r
2143 * @before <p>This is just a test.</p>
\r
2152 * Set the CSS width of every matched element. Be sure to include
\r
2153 * the "px" (or other unit of measurement) after the number that you
\r
2154 * specify, otherwise you might get strange results.
\r
2156 * @example $("p").width("20px");
\r
2157 * @before <p>This is just a test.</p>
\r
2158 * @result <p style="width:20px;">This is just a test.</p>
\r
2162 * @param String val Set the CSS property to the specified value.
\r
2167 * Get the current CSS height of the first matched element.
\r
2169 * @example $("p").height();
\r
2170 * @before <p>This is just a test.</p>
\r
2179 * Set the CSS height of every matched element. Be sure to include
\r
2180 * the "px" (or other unit of measurement) after the number that you
\r
2181 * specify, otherwise you might get strange results.
\r
2183 * @example $("p").height("20px");
\r
2184 * @before <p>This is just a test.</p>
\r
2185 * @result <p style="height:20px;">This is just a test.</p>
\r
2189 * @param String val Set the CSS property to the specified value.
\r
2194 * Get the current CSS top of the first matched element.
\r
2196 * @example $("p").top();
\r
2197 * @before <p>This is just a test.</p>
\r
2206 * Set the CSS top of every matched element. Be sure to include
\r
2207 * the "px" (or other unit of measurement) after the number that you
\r
2208 * specify, otherwise you might get strange results.
\r
2210 * @example $("p").top("20px");
\r
2211 * @before <p>This is just a test.</p>
\r
2212 * @result <p style="top:20px;">This is just a test.</p>
\r
2216 * @param String val Set the CSS property to the specified value.
\r
2221 * Get the current CSS left of the first matched element.
\r
2223 * @example $("p").left();
\r
2224 * @before <p>This is just a test.</p>
\r
2233 * Set the CSS left of every matched element. Be sure to include
\r
2234 * the "px" (or other unit of measurement) after the number that you
\r
2235 * specify, otherwise you might get strange results.
\r
2237 * @example $("p").left("20px");
\r
2238 * @before <p>This is just a test.</p>
\r
2239 * @result <p style="left:20px;">This is just a test.</p>
\r
2243 * @param String val Set the CSS property to the specified value.
\r
2248 * Get the current CSS position of the first matched element.
\r
2250 * @example $("p").position();
\r
2251 * @before <p>This is just a test.</p>
\r
2252 * @result "static"
\r
2260 * Set the CSS position of every matched element.
\r
2262 * @example $("p").position("relative");
\r
2263 * @before <p>This is just a test.</p>
\r
2264 * @result <p style="position:relative;">This is just a test.</p>
\r
2268 * @param String val Set the CSS property to the specified value.
\r
2273 * Get the current CSS float of the first matched element.
\r
2275 * @example $("p").float();
\r
2276 * @before <p>This is just a test.</p>
\r
2285 * Set the CSS float of every matched element.
\r
2287 * @example $("p").float("left");
\r
2288 * @before <p>This is just a test.</p>
\r
2289 * @result <p style="float:left;">This is just a test.</p>
\r
2293 * @param String val Set the CSS property to the specified value.
\r
2298 * Get the current CSS overflow of the first matched element.
\r
2300 * @example $("p").overflow();
\r
2301 * @before <p>This is just a test.</p>
\r
2310 * Set the CSS overflow of every matched element.
\r
2312 * @example $("p").overflow("auto");
\r
2313 * @before <p>This is just a test.</p>
\r
2314 * @result <p style="overflow:auto;">This is just a test.</p>
\r
2318 * @param String val Set the CSS property to the specified value.
\r
2323 * Get the current CSS color of the first matched element.
\r
2325 * @example $("p").color();
\r
2326 * @before <p>This is just a test.</p>
\r
2335 * Set the CSS color of every matched element.
\r
2337 * @example $("p").color("blue");
\r
2338 * @before <p>This is just a test.</p>
\r
2339 * @result <p style="color:blue;">This is just a test.</p>
\r
2343 * @param String val Set the CSS property to the specified value.
\r
2348 * Get the current CSS background of the first matched element.
\r
2350 * @example $("p").background();
\r
2351 * @before <p style="background:blue;">This is just a test.</p>
\r
2354 * @name background
\r
2360 * Set the CSS background of every matched element.
\r
2362 * @example $("p").background("blue");
\r
2363 * @before <p>This is just a test.</p>
\r
2364 * @result <p style="background:blue;">This is just a test.</p>
\r
2366 * @name background
\r
2368 * @param String val Set the CSS property to the specified value.
\r
2372 css: "width,height,top,left,position,float,overflow,color,background".split(","),
\r
2375 * Reduce the set of matched elements to a single element.
\r
2376 * The position of the element in the set of matched elements
\r
2377 * starts at 0 and goes to length - 1.
\r
2379 * @example $("p").eq(1)
\r
2380 * @before <p>This is just a test.</p><p>So is this</p>
\r
2381 * @result [ <p>So is this</p> ]
\r
2385 * @param Number pos The index of the element that you wish to limit to.
\r
2390 * Reduce the set of matched elements to all elements before a given position.
\r
2391 * The position of the element in the set of matched elements
\r
2392 * starts at 0 and goes to length - 1.
\r
2394 * @example $("p").lt(1)
\r
2395 * @before <p>This is just a test.</p><p>So is this</p>
\r
2396 * @result [ <p>This is just a test.</p> ]
\r
2400 * @param Number pos Reduce the set to all elements below this position.
\r
2405 * Reduce the set of matched elements to all elements after a given position.
\r
2406 * The position of the element in the set of matched elements
\r
2407 * starts at 0 and goes to length - 1.
\r
2409 * @example $("p").gt(0)
\r
2410 * @before <p>This is just a test.</p><p>So is this</p>
\r
2411 * @result [ <p>So is this</p> ]
\r
2415 * @param Number pos Reduce the set to all elements after this position.
\r
2420 * Filter the set of elements to those that contain the specified text.
\r
2422 * @example $("p").contains("test")
\r
2423 * @before <p>This is just a test.</p><p>So is this</p>
\r
2424 * @result [ <p>This is just a test.</p> ]
\r
2428 * @param String str The string that will be contained within the text of an element.
\r
2429 * @cat DOM/Traversing
\r
2432 filter: [ "eq", "lt", "gt", "contains" ],
\r
2436 * Get the current value of the first matched element.
\r
2438 * @example $("input").val();
\r
2439 * @before <input type="text" value="some text"/>
\r
2440 * @result "some text"
\r
2444 * @cat DOM/Attributes
\r
2448 * Set the value of every matched element.
\r
2450 * @example $("input").val("test");
\r
2451 * @before <input type="text" value="some text"/>
\r
2452 * @result <input type="text" value="test"/>
\r
2456 * @param String val Set the property to the specified value.
\r
2457 * @cat DOM/Attributes
\r
2462 * Get the html contents of the first matched element.
\r
2464 * @example $("div").html();
\r
2465 * @before <div><input/></div>
\r
2466 * @result <input/>
\r
2470 * @cat DOM/Attributes
\r
2474 * Set the html contents of every matched element.
\r
2476 * @example $("div").html("<b>new stuff</b>");
\r
2477 * @before <div><input/></div>
\r
2478 * @result <div><b>new stuff</b></div>
\r
2482 * @param String val Set the html contents to the specified value.
\r
2483 * @cat DOM/Attributes
\r
2485 html: "innerHTML",
\r
2488 * Get the current id of the first matched element.
\r
2490 * @example $("input").id();
\r
2491 * @before <input type="text" id="test" value="some text"/>
\r
2496 * @cat DOM/Attributes
\r
2500 * Set the id of every matched element.
\r
2502 * @example $("input").id("newid");
\r
2503 * @before <input type="text" id="test" value="some text"/>
\r
2504 * @result <input type="text" id="newid" value="some text"/>
\r
2508 * @param String val Set the property to the specified value.
\r
2509 * @cat DOM/Attributes
\r
2514 * Get the current title of the first matched element.
\r
2516 * @example $("img").title();
\r
2517 * @before <img src="test.jpg" title="my image"/>
\r
2518 * @result "my image"
\r
2522 * @cat DOM/Attributes
\r
2526 * Set the title of every matched element.
\r
2528 * @example $("img").title("new title");
\r
2529 * @before <img src="test.jpg" title="my image"/>
\r
2530 * @result <img src="test.jpg" title="new image"/>
\r
2534 * @param String val Set the property to the specified value.
\r
2535 * @cat DOM/Attributes
\r
2540 * Get the current name of the first matched element.
\r
2542 * @example $("input").name();
\r
2543 * @before <input type="text" name="username"/>
\r
2544 * @result "username"
\r
2548 * @cat DOM/Attributes
\r
2552 * Set the name of every matched element.
\r
2554 * @example $("input").name("user");
\r
2555 * @before <input type="text" name="username"/>
\r
2556 * @result <input type="text" name="user"/>
\r
2560 * @param String val Set the property to the specified value.
\r
2561 * @cat DOM/Attributes
\r
2566 * Get the current href of the first matched element.
\r
2568 * @example $("a").href();
\r
2569 * @before <a href="test.html">my link</a>
\r
2570 * @result "test.html"
\r
2574 * @cat DOM/Attributes
\r
2578 * Set the href of every matched element.
\r
2580 * @example $("a").href("test2.html");
\r
2581 * @before <a href="test.html">my link</a>
\r
2582 * @result <a href="test2.html">my link</a>
\r
2586 * @param String val Set the property to the specified value.
\r
2587 * @cat DOM/Attributes
\r
2592 * Get the current src of the first matched element.
\r
2594 * @example $("img").src();
\r
2595 * @before <img src="test.jpg" title="my image"/>
\r
2596 * @result "test.jpg"
\r
2600 * @cat DOM/Attributes
\r
2604 * Set the src of every matched element.
\r
2606 * @example $("img").src("test2.jpg");
\r
2607 * @before <img src="test.jpg" title="my image"/>
\r
2608 * @result <img src="test2.jpg" title="my image"/>
\r
2612 * @param String val Set the property to the specified value.
\r
2613 * @cat DOM/Attributes
\r
2618 * Get the current rel of the first matched element.
\r
2620 * @example $("a").rel();
\r
2621 * @before <a href="test.html" rel="nofollow">my link</a>
\r
2622 * @result "nofollow"
\r
2626 * @cat DOM/Attributes
\r
2630 * Set the rel of every matched element.
\r
2632 * @example $("a").rel("nofollow");
\r
2633 * @before <a href="test.html">my link</a>
\r
2634 * @result <a href="test.html" rel="nofollow">my link</a>
\r
2638 * @param String val Set the property to the specified value.
\r
2639 * @cat DOM/Attributes
\r
2646 * Get a set of elements containing the unique parents of the matched
\r
2647 * set of elements.
\r
2649 * @example $("p").parent()
\r
2650 * @before <div><p>Hello</p><p>Hello</p></div>
\r
2651 * @result [ <div><p>Hello</p><p>Hello</p></div> ]
\r
2655 * @cat DOM/Traversing
\r
2659 * Get a set of elements containing the unique parents of the matched
\r
2660 * set of elements, and filtered by an expression.
\r
2662 * @example $("p").parent(".selected")
\r
2663 * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
\r
2664 * @result [ <div class="selected"><p>Hello Again</p></div> ]
\r
2668 * @param String expr An expression to filter the parents with
\r
2669 * @cat DOM/Traversing
\r
2671 parent: "a.parentNode",
\r
2674 * Get a set of elements containing the unique ancestors of the matched
\r
2675 * set of elements (except for the root element).
\r
2677 * @example $("span").ancestors()
\r
2678 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
\r
2679 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
\r
2683 * @cat DOM/Traversing
\r
2687 * Get a set of elements containing the unique ancestors of the matched
\r
2688 * set of elements, and filtered by an expression.
\r
2690 * @example $("span").ancestors("p")
\r
2691 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
\r
2692 * @result [ <p><span>Hello</span></p> ]
\r
2696 * @param String expr An expression to filter the ancestors with
\r
2697 * @cat DOM/Traversing
\r
2699 ancestors: jQuery.parents,
\r
2702 * Get a set of elements containing the unique ancestors of the matched
\r
2703 * set of elements (except for the root element).
\r
2705 * @example $("span").ancestors()
\r
2706 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
\r
2707 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
\r
2711 * @cat DOM/Traversing
\r
2715 * Get a set of elements containing the unique ancestors of the matched
\r
2716 * set of elements, and filtered by an expression.
\r
2718 * @example $("span").ancestors("p")
\r
2719 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
\r
2720 * @result [ <p><span>Hello</span></p> ]
\r
2724 * @param String expr An expression to filter the ancestors with
\r
2725 * @cat DOM/Traversing
\r
2727 parents: jQuery.parents,
\r
2730 * Get a set of elements containing the unique next siblings of each of the
\r
2731 * matched set of elements.
\r
2733 * It only returns the very next sibling, not all next siblings.
\r
2735 * @example $("p").next()
\r
2736 * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
\r
2737 * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
\r
2741 * @cat DOM/Traversing
\r
2745 * Get a set of elements containing the unique next siblings of each of the
\r
2746 * matched set of elements, and filtered by an expression.
\r
2748 * It only returns the very next sibling, not all next siblings.
\r
2750 * @example $("p").next(".selected")
\r
2751 * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
\r
2752 * @result [ <p class="selected">Hello Again</p> ]
\r
2756 * @param String expr An expression to filter the next Elements with
\r
2757 * @cat DOM/Traversing
\r
2759 next: "jQuery.sibling(a).next",
\r
2762 * Get a set of elements containing the unique previous siblings of each of the
\r
2763 * matched set of elements.
\r
2765 * It only returns the immediately previous sibling, not all previous siblings.
\r
2767 * @example $("p").prev()
\r
2768 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
\r
2769 * @result [ <div><span>Hello Again</span></div> ]
\r
2773 * @cat DOM/Traversing
\r
2777 * Get a set of elements containing the unique previous siblings of each of the
\r
2778 * matched set of elements, and filtered by an expression.
\r
2780 * It only returns the immediately previous sibling, not all previous siblings.
\r
2782 * @example $("p").prev(".selected")
\r
2783 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
\r
2784 * @result [ <div><span>Hello</span></div> ]
\r
2788 * @param String expr An expression to filter the previous Elements with
\r
2789 * @cat DOM/Traversing
\r
2791 prev: "jQuery.sibling(a).prev",
\r
2794 * Get a set of elements containing all of the unique siblings of each of the
\r
2795 * matched set of elements.
\r
2797 * @example $("div").siblings()
\r
2798 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
\r
2799 * @result [ <p>Hello</p>, <p>And Again</p> ]
\r
2803 * @cat DOM/Traversing
\r
2807 * Get a set of elements containing all of the unique siblings of each of the
\r
2808 * matched set of elements, and filtered by an expression.
\r
2810 * @example $("div").siblings(".selected")
\r
2811 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
\r
2812 * @result [ <p class="selected">Hello Again</p> ]
\r
2816 * @param String expr An expression to filter the sibling Elements with
\r
2817 * @cat DOM/Traversing
\r
2819 siblings: "jQuery.sibling(a, null, true)",
\r
2823 * Get a set of elements containing all of the unique children of each of the
\r
2824 * matched set of elements.
\r
2826 * @example $("div").children()
\r
2827 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
\r
2828 * @result [ <span>Hello Again</span> ]
\r
2832 * @cat DOM/Traversing
\r
2836 * Get a set of elements containing all of the unique children of each of the
\r
2837 * matched set of elements, and filtered by an expression.
\r
2839 * @example $("div").children(".selected")
\r
2840 * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
\r
2841 * @result [ <p class="selected">Hello Again</p> ]
\r
2845 * @param String expr An expression to filter the child Elements with
\r
2846 * @cat DOM/Traversing
\r
2848 children: "jQuery.sibling(a.firstChild)"
\r
2854 * Remove an attribute from each of the matched elements.
\r
2856 * @example $("input").removeAttr("disabled")
\r
2857 * @before <input disabled="disabled"/>
\r
2858 * @result <input/>
\r
2860 * @name removeAttr
\r
2862 * @param String name The name of the attribute to remove.
\r
2865 removeAttr: function( key ) {
\r
2866 jQuery.attr( this, key, "" );
\r
2867 this.removeAttribute( key );
\r
2871 * Displays each of the set of matched elements if they are hidden.
\r
2873 * @example $("p").show()
\r
2874 * @before <p style="display: none">Hello</p>
\r
2875 * @result [ <p style="display: block">Hello</p> ]
\r
2882 this.style.display = this.oldblock ? this.oldblock : "";
\r
2883 if ( jQuery.css(this,"display") == "none" )
\r
2884 this.style.display = "block";
\r
2888 * Hides each of the set of matched elements if they are shown.
\r
2890 * @example $("p").hide()
\r
2891 * @before <p>Hello</p>
\r
2892 * @result [ <p style="display: none">Hello</p> ]
\r
2894 * var pass = true, div = $("div");
\r
2895 * div.hide().each(function(){
\r
2896 * if ( this.style.display != "none" ) pass = false;
\r
2898 * ok( pass, "Hide" );
\r
2905 this.oldblock = this.oldblock || jQuery.css(this,"display");
\r
2906 if ( this.oldblock == "none" )
\r
2907 this.oldblock = "block";
\r
2908 this.style.display = "none";
\r
2912 * Toggles each of the set of matched elements. If they are shown,
\r
2913 * toggle makes them hidden. If they are hidden, toggle
\r
2914 * makes them shown.
\r
2916 * @example $("p").toggle()
\r
2917 * @before <p>Hello</p><p style="display: none">Hello Again</p>
\r
2918 * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
\r
2924 toggle: function(){
\r
2925 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
\r
2929 * Adds the specified class to each of the set of matched elements.
\r
2931 * @example $("p").addClass("selected")
\r
2932 * @before <p>Hello</p>
\r
2933 * @result [ <p class="selected">Hello</p> ]
\r
2937 * @param String class A CSS class to add to the elements
\r
2940 addClass: function(c){
\r
2941 jQuery.className.add(this,c);
\r
2945 * Removes the specified class from the set of matched elements.
\r
2947 * @example $("p").removeClass("selected")
\r
2948 * @before <p class="selected">Hello</p>
\r
2949 * @result [ <p>Hello</p> ]
\r
2951 * @name removeClass
\r
2953 * @param String class A CSS class to remove from the elements
\r
2956 removeClass: function(c){
\r
2957 jQuery.className.remove(this,c);
\r
2961 * Adds the specified class if it is not present, removes it if it is
\r
2964 * @example $("p").toggleClass("selected")
\r
2965 * @before <p>Hello</p><p class="selected">Hello Again</p>
\r
2966 * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
\r
2968 * @name toggleClass
\r
2970 * @param String class A CSS class with which to toggle the elements
\r
2973 toggleClass: function( c ){
\r
2974 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
\r
2978 * Removes all matched elements from the DOM. This does NOT remove them from the
\r
2979 * jQuery object, allowing you to use the matched elements further.
\r
2981 * @example $("p").remove();
\r
2982 * @before <p>Hello</p> how are <p>you?</p>
\r
2987 * @cat DOM/Manipulation
\r
2991 * Removes only elements (out of the list of matched elements) that match
\r
2992 * the specified jQuery expression. This does NOT remove them from the
\r
2993 * jQuery object, allowing you to use the matched elements further.
\r
2995 * @example $("p").remove(".hello");
\r
2996 * @before <p class="hello">Hello</p> how are <p>you?</p>
\r
2997 * @result how are <p>you?</p>
\r
3001 * @param String expr A jQuery expression to filter elements by.
\r
3002 * @cat DOM/Manipulation
\r
3004 remove: function(a){
\r
3005 if ( !a || jQuery.filter( a, [this] ).r )
\r
3006 this.parentNode.removeChild( this );
\r
3010 * Removes all child nodes from the set of matched elements.
\r
3012 * @example $("p").empty()
\r
3013 * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
\r
3014 * @result [ <p></p> ]
\r
3018 * @cat DOM/Manipulation
\r
3020 empty: function(){
\r
3021 while ( this.firstChild )
\r
3022 this.removeChild( this.firstChild );
\r
3026 * Binds a handler to a particular event (like click) for each matched element.
\r
3027 * The event handler is passed an event object that you can use to prevent
\r
3028 * default behaviour. To stop both default action and event bubbling, your handler
\r
3029 * has to return false.
\r
3031 * @example $("p").bind( "click", function() {
\r
3032 * alert( $(this).text() );
\r
3034 * @before <p>Hello</p>
\r
3035 * @result alert("Hello")
\r
3037 * @example $("form").bind( "submit", function() { return false; } )
\r
3038 * @desc Cancel a default action and prevent it from bubbling by returning false
\r
3039 * from your function.
\r
3041 * @example $("form").bind( "submit", function(event) {
\r
3042 * event.preventDefault();
\r
3044 * @desc Cancel only the default action by using the preventDefault method.
\r
3047 * @example $("form").bind( "submit", function(event) {
\r
3048 * event.stopPropagation();
\r
3050 * @desc Stop only an event from bubbling by using the stopPropagation method.
\r
3054 * @param String type An event type
\r
3055 * @param Function fn A function to bind to the event on each of the set of matched elements
\r
3058 bind: function( type, fn ) {
\r
3059 jQuery.event.add( this, type, fn );
\r
3063 * The opposite of bind, removes a bound event from each of the matched
\r
3064 * elements. You must pass the identical function that was used in the original
\r
3067 * @example $("p").unbind( "click", function() { alert("Hello"); } )
\r
3068 * @before <p onclick="alert('Hello');">Hello</p>
\r
3069 * @result [ <p>Hello</p> ]
\r
3073 * @param String type An event type
\r
3074 * @param Function fn A function to unbind from the event on each of the set of matched elements
\r
3079 * Removes all bound events of a particular type from each of the matched
\r
3082 * @example $("p").unbind( "click" )
\r
3083 * @before <p onclick="alert('Hello');">Hello</p>
\r
3084 * @result [ <p>Hello</p> ]
\r
3088 * @param String type An event type
\r
3093 * Removes all bound events from each of the matched elements.
\r
3095 * @example $("p").unbind()
\r
3096 * @before <p onclick="alert('Hello');">Hello</p>
\r
3097 * @result [ <p>Hello</p> ]
\r
3103 unbind: function( type, fn ) {
\r
3104 jQuery.event.remove( this, type, fn );
\r
3108 * Trigger a type of event on every matched element.
\r
3110 * @example $("p").trigger("click")
\r
3111 * @before <p click="alert('hello')">Hello</p>
\r
3112 * @result alert('hello')
\r
3116 * @param String type An event type to trigger.
\r
3119 trigger: function( type, data ) {
\r
3120 jQuery.event.trigger( type, data, this );
\r