3 // We're overriding the old toggle function, so
4 // remember it for later
5 _toggle: jQuery.fn.toggle,
8 * Toggle between two function calls every other click.
9 * Whenever a matched element is clicked, the first specified function
10 * is fired, when clicked again, the second is fired. All subsequent
11 * clicks continue to rotate through the two functions.
13 * @example $("p").toggle(function(){
14 * $(this).addClass("selected");
16 * $(this).removeClass("selected");
21 * @param Function even The function to execute on every even click.
22 * @param Function odd The function to execute on every odd click.
25 toggle: function(a,b) {
26 // If two functions are passed in, we're
27 // toggling on a click
28 return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){
29 // Figure out which function to execute
30 this.last = this.last == a ? b : a;
32 // Make sure that clicks stop
35 // and execute the function
36 return this.last.apply( this, [e] ) || false;
39 // Otherwise, execute the old toggle function
40 this._toggle.apply( this, arguments );
44 * A method for simulating hovering (moving the mouse on, and off,
45 * an object). This is a custom method which provides an 'in' to a
48 * Whenever the mouse cursor is moved over a matched
49 * element, the first specified function is fired. Whenever the mouse
50 * moves off of the element, the second specified function fires.
51 * Additionally, checks are in place to see if the mouse is still within
52 * the specified element itself (for example, an image inside of a div),
53 * and if it is, it will continue to 'hover', and not move out
54 * (a common error in using a mouseout event handler).
56 * @example $("p").hover(function(){
57 * $(this).addClass("over");
59 * $(this).addClass("out");
64 * @param Function over The function to fire whenever the mouse is moved over a matched element.
65 * @param Function out The function to fire whenever the mouse is moved off of a matched element.
68 hover: function(f,g) {
70 // A private function for haandling mouse 'hovering'
71 function handleHover(e) {
72 // Check if mouse(over|out) are still within the same parent element
73 var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
75 // Traverse up the tree
76 while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
78 // If we actually just moused on to a sub-element, ignore it
79 if ( p == this ) return false;
81 // Execute the right function
82 return (e.type == "mouseover" ? f : g).apply(this, [e]);
85 // Bind the function to the two event listeners
86 return this.mouseover(handleHover).mouseout(handleHover);
90 * Bind a function to be executed whenever the DOM is ready to be
91 * traversed and manipulated. This is probably the most important
92 * function included in the event module, as it can greatly improve
93 * the response times of your web applications.
95 * In a nutshell, this is a solid replacement for using window.onload,
96 * and attaching a function to that. By using this method, your bound Function
97 * will be called the instant the DOM is ready to be read and manipulated,
98 * which is exactly what 99.99% of all Javascript code needs to run.
100 * Please ensure you have no code in your <body> onload event handler,
101 * otherwise $(document).ready() may not fire.
103 * You can have as many $(document).ready events on your page as you like.
105 * @example $(document).ready(function(){ Your code here... });
109 * @param Function fn The function to be executed when the DOM is ready.
113 // If the DOM is already ready
114 if ( jQuery.isReady )
115 // Execute the function immediately
118 // Otherwise, remember the function for later
120 // Add the function to the wait list
121 jQuery.readyList.push( f );
130 * All the code that makes DOM Ready work nicely.
135 // Handle when the DOM is ready
137 // Make sure that the DOM is not already loaded
138 if ( !jQuery.isReady ) {
139 // Remember that the DOM is ready
140 jQuery.isReady = true;
142 // If there are functions bound, to execute
143 if ( jQuery.readyList ) {
144 // Execute all of them
145 for ( var i = 0; i < jQuery.readyList.length; i++ )
146 jQuery.readyList[i].apply( document );
148 // Reset the list of functions
149 jQuery.readyList = null;
151 // Remove event lisenter to avoid memory leak
152 if ( jQuery.browser.mozilla || jQuery.browser.opera )
153 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
161 * Bind a function to the scroll event of each matched element.
163 * @example $("p").scroll( function() { alert("Hello"); } );
164 * @before <p>Hello</p>
165 * @result <p onscroll="alert('Hello');">Hello</p>
169 * @param Function fn A function to bind to the scroll event on each of the matched elements.
170 * @cat Events/Browser
174 * Trigger the scroll event of each matched element. This causes all of the functions
175 * that have been bound to thet scroll event to be executed.
177 * @example $("p").scroll();
178 * @before <p onscroll="alert('Hello');">Hello</p>
179 * @result alert('Hello');
183 * @cat Events/Browser
187 * Bind a function to the scroll event of each matched element, which will only be executed once.
188 * Unlike a call to the normal .scroll() method, calling .onescroll() causes the bound function to be
189 * only executed the first time it is triggered, and never again (unless it is re-bound).
191 * @example $("p").onescroll( function() { alert("Hello"); } );
192 * @before <p onscroll="alert('Hello');">Hello</p>
193 * @result alert('Hello'); // Only executed for the first scroll
197 * @param Function fn A function to bind to the scroll event on each of the matched elements.
198 * @cat Events/Browser
202 * Removes a bound scroll event from each of the matched
203 * elements. You must pass the identical function that was used in the original
206 * @example $("p").unscroll( myFunction );
207 * @before <p onscroll="myFunction">Hello</p>
208 * @result <p>Hello</p>
212 * @param Function fn A function to unbind from the scroll event on each of the matched elements.
213 * @cat Events/Browser
217 * Removes all bound scroll events from each of the matched elements.
219 * @example $("p").unscroll();
220 * @before <p onscroll="alert('Hello');">Hello</p>
221 * @result <p>Hello</p>
225 * @cat Events/Browser
229 * Bind a function to the submit event of each matched element.
231 * @example $("#myform").submit( function() {
232 * return $("input", this).val().length > 0;
234 * @before <form id="myform"><input /></form>
235 * @desc Prevents the form submission when the input has no value entered.
239 * @param Function fn A function to bind to the submit event on each of the matched elements.
244 * Trigger the submit event of each matched element. This causes all of the functions
245 * that have been bound to thet submit event to be executed.
247 * Note: This does not execute the submit method of the form element! If you need to
248 * submit the form via code, you have to use the DOM method, eg. $("form")[0].submit();
250 * @example $("form").submit();
251 * @desc Triggers all submit events registered for forms, but does not submit the form
259 * Bind a function to the submit event of each matched element, which will only be executed once.
260 * Unlike a call to the normal .submit() method, calling .onesubmit() causes the bound function to be
261 * only executed the first time it is triggered, and never again (unless it is re-bound).
263 * @example $("p").onesubmit( function() { alert("Hello"); } );
264 * @before <p onsubmit="alert('Hello');">Hello</p>
265 * @result alert('Hello'); // Only executed for the first submit
269 * @param Function fn A function to bind to the submit event on each of the matched elements.
274 * Removes a bound submit event from each of the matched
275 * elements. You must pass the identical function that was used in the original
278 * @example $("p").unsubmit( myFunction );
279 * @before <p onsubmit="myFunction">Hello</p>
280 * @result <p>Hello</p>
284 * @param Function fn A function to unbind from the submit event on each of the matched elements.
289 * Removes all bound submit events from each of the matched elements.
291 * @example $("p").unsubmit();
292 * @before <p onsubmit="alert('Hello');">Hello</p>
293 * @result <p>Hello</p>
301 * Bind a function to the focus event of each matched element.
303 * @example $("p").focus( function() { alert("Hello"); } );
304 * @before <p>Hello</p>
305 * @result <p onfocus="alert('Hello');">Hello</p>
309 * @param Function fn A function to bind to the focus event on each of the matched elements.
314 * Trigger the focus event of each matched element. This causes all of the functions
315 * that have been bound to thet focus event to be executed.
317 * @example $("p").focus();
318 * @before <p onfocus="alert('Hello');">Hello</p>
319 * @result alert('Hello');
327 * Bind a function to the focus event of each matched element, which will only be executed once.
328 * Unlike a call to the normal .focus() method, calling .onefocus() causes the bound function to be
329 * only executed the first time it is triggered, and never again (unless it is re-bound).
331 * @example $("p").onefocus( function() { alert("Hello"); } );
332 * @before <p onfocus="alert('Hello');">Hello</p>
333 * @result alert('Hello'); // Only executed for the first focus
337 * @param Function fn A function to bind to the focus event on each of the matched elements.
342 * Removes a bound focus event from each of the matched
343 * elements. You must pass the identical function that was used in the original
346 * @example $("p").unfocus( myFunction );
347 * @before <p onfocus="myFunction">Hello</p>
348 * @result <p>Hello</p>
352 * @param Function fn A function to unbind from the focus event on each of the matched elements.
357 * Removes all bound focus events from each of the matched elements.
359 * @example $("p").unfocus();
360 * @before <p onfocus="alert('Hello');">Hello</p>
361 * @result <p>Hello</p>
369 * Bind a function to the keydown event of each matched element.
371 * @example $("p").keydown( function() { alert("Hello"); } );
372 * @before <p>Hello</p>
373 * @result <p onkeydown="alert('Hello');">Hello</p>
377 * @param Function fn A function to bind to the keydown event on each of the matched elements.
378 * @cat Events/Keyboard
382 * Trigger the keydown event of each matched element. This causes all of the functions
383 * that have been bound to thet keydown event to be executed.
385 * @example $("p").keydown();
386 * @before <p onkeydown="alert('Hello');">Hello</p>
387 * @result alert('Hello');
391 * @cat Events/Keyboard
395 * Bind a function to the keydown event of each matched element, which will only be executed once.
396 * Unlike a call to the normal .keydown() method, calling .onekeydown() causes the bound function to be
397 * only executed the first time it is triggered, and never again (unless it is re-bound).
399 * @example $("p").onekeydown( function() { alert("Hello"); } );
400 * @before <p onkeydown="alert('Hello');">Hello</p>
401 * @result alert('Hello'); // Only executed for the first keydown
405 * @param Function fn A function to bind to the keydown event on each of the matched elements.
406 * @cat Events/Keyboard
410 * Removes a bound keydown event from each of the matched
411 * elements. You must pass the identical function that was used in the original
414 * @example $("p").unkeydown( myFunction );
415 * @before <p onkeydown="myFunction">Hello</p>
416 * @result <p>Hello</p>
420 * @param Function fn A function to unbind from the keydown event on each of the matched elements.
421 * @cat Events/Keyboard
425 * Removes all bound keydown events from each of the matched elements.
427 * @example $("p").unkeydown();
428 * @before <p onkeydown="alert('Hello');">Hello</p>
429 * @result <p>Hello</p>
433 * @cat Events/Keyboard
437 * Bind a function to the dblclick event of each matched element.
439 * @example $("p").dblclick( function() { alert("Hello"); } );
440 * @before <p>Hello</p>
441 * @result <p ondblclick="alert('Hello');">Hello</p>
445 * @param Function fn A function to bind to the dblclick event on each of the matched elements.
450 * Trigger the dblclick event of each matched element. This causes all of the functions
451 * that have been bound to thet dblclick event to be executed.
453 * @example $("p").dblclick();
454 * @before <p ondblclick="alert('Hello');">Hello</p>
455 * @result alert('Hello');
463 * Bind a function to the dblclick event of each matched element, which will only be executed once.
464 * Unlike a call to the normal .dblclick() method, calling .onedblclick() causes the bound function to be
465 * only executed the first time it is triggered, and never again (unless it is re-bound).
467 * @example $("p").onedblclick( function() { alert("Hello"); } );
468 * @before <p ondblclick="alert('Hello');">Hello</p>
469 * @result alert('Hello'); // Only executed for the first dblclick
473 * @param Function fn A function to bind to the dblclick event on each of the matched elements.
478 * Removes a bound dblclick event from each of the matched
479 * elements. You must pass the identical function that was used in the original
482 * @example $("p").undblclick( myFunction );
483 * @before <p ondblclick="myFunction">Hello</p>
484 * @result <p>Hello</p>
488 * @param Function fn A function to unbind from the dblclick event on each of the matched elements.
493 * Removes all bound dblclick events from each of the matched elements.
495 * @example $("p").undblclick();
496 * @before <p ondblclick="alert('Hello');">Hello</p>
497 * @result <p>Hello</p>
505 * Bind a function to the keypress event of each matched element.
507 * @example $("p").keypress( function() { alert("Hello"); } );
508 * @before <p>Hello</p>
509 * @result <p onkeypress="alert('Hello');">Hello</p>
513 * @param Function fn A function to bind to the keypress event on each of the matched elements.
514 * @cat Events/Keyboard
518 * Trigger the keypress event of each matched element. This causes all of the functions
519 * that have been bound to thet keypress event to be executed.
521 * @example $("p").keypress();
522 * @before <p onkeypress="alert('Hello');">Hello</p>
523 * @result alert('Hello');
527 * @cat Events/Keyboard
531 * Bind a function to the keypress event of each matched element, which will only be executed once.
532 * Unlike a call to the normal .keypress() method, calling .onekeypress() causes the bound function to be
533 * only executed the first time it is triggered, and never again (unless it is re-bound).
535 * @example $("p").onekeypress( function() { alert("Hello"); } );
536 * @before <p onkeypress="alert('Hello');">Hello</p>
537 * @result alert('Hello'); // Only executed for the first keypress
541 * @param Function fn A function to bind to the keypress event on each of the matched elements.
542 * @cat Events/Keyboard
546 * Removes a bound keypress event from each of the matched
547 * elements. You must pass the identical function that was used in the original
550 * @example $("p").unkeypress( myFunction );
551 * @before <p onkeypress="myFunction">Hello</p>
552 * @result <p>Hello</p>
556 * @param Function fn A function to unbind from the keypress event on each of the matched elements.
557 * @cat Events/Keyboard
561 * Removes all bound keypress events from each of the matched elements.
563 * @example $("p").unkeypress();
564 * @before <p onkeypress="alert('Hello');">Hello</p>
565 * @result <p>Hello</p>
569 * @cat Events/Keyboard
573 * Bind a function to the error event of each matched element.
575 * @example $("p").error( function() { alert("Hello"); } );
576 * @before <p>Hello</p>
577 * @result <p onerror="alert('Hello');">Hello</p>
581 * @param Function fn A function to bind to the error event on each of the matched elements.
582 * @cat Events/Browser
586 * Trigger the error event of each matched element. This causes all of the functions
587 * that have been bound to thet error event to be executed.
589 * @example $("p").error();
590 * @before <p onerror="alert('Hello');">Hello</p>
591 * @result alert('Hello');
595 * @cat Events/Browser
599 * Bind a function to the error event of each matched element, which will only be executed once.
600 * Unlike a call to the normal .error() method, calling .oneerror() causes the bound function to be
601 * only executed the first time it is triggered, and never again (unless it is re-bound).
603 * @example $("p").oneerror( function() { alert("Hello"); } );
604 * @before <p onerror="alert('Hello');">Hello</p>
605 * @result alert('Hello'); // Only executed for the first error
609 * @param Function fn A function to bind to the error event on each of the matched elements.
610 * @cat Events/Browser
614 * Removes a bound error event from each of the matched
615 * elements. You must pass the identical function that was used in the original
618 * @example $("p").unerror( myFunction );
619 * @before <p onerror="myFunction">Hello</p>
620 * @result <p>Hello</p>
624 * @param Function fn A function to unbind from the error event on each of the matched elements.
625 * @cat Events/Browser
629 * Removes all bound error events from each of the matched elements.
631 * @example $("p").unerror();
632 * @before <p onerror="alert('Hello');">Hello</p>
633 * @result <p>Hello</p>
637 * @cat Events/Browser
641 * Bind a function to the blur event of each matched element.
643 * @example $("p").blur( function() { alert("Hello"); } );
644 * @before <p>Hello</p>
645 * @result <p onblur="alert('Hello');">Hello</p>
649 * @param Function fn A function to bind to the blur event on each of the matched elements.
654 * Trigger the blur event of each matched element. This causes all of the functions
655 * that have been bound to thet blur event to be executed.
657 * @example $("p").blur();
658 * @before <p onblur="alert('Hello');">Hello</p>
659 * @result alert('Hello');
667 * Bind a function to the blur event of each matched element, which will only be executed once.
668 * Unlike a call to the normal .blur() method, calling .oneblur() causes the bound function to be
669 * only executed the first time it is triggered, and never again (unless it is re-bound).
671 * @example $("p").oneblur( function() { alert("Hello"); } );
672 * @before <p onblur="alert('Hello');">Hello</p>
673 * @result alert('Hello'); // Only executed for the first blur
677 * @param Function fn A function to bind to the blur event on each of the matched elements.
682 * Removes a bound blur event from each of the matched
683 * elements. You must pass the identical function that was used in the original
686 * @example $("p").unblur( myFunction );
687 * @before <p onblur="myFunction">Hello</p>
688 * @result <p>Hello</p>
692 * @param Function fn A function to unbind from the blur event on each of the matched elements.
697 * Removes all bound blur events from each of the matched elements.
699 * @example $("p").unblur();
700 * @before <p onblur="alert('Hello');">Hello</p>
701 * @result <p>Hello</p>
709 * Bind a function to the load event of each matched element.
711 * @example $("p").load( function() { alert("Hello"); } );
712 * @before <p>Hello</p>
713 * @result <p onload="alert('Hello');">Hello</p>
717 * @param Function fn A function to bind to the load event on each of the matched elements.
718 * @cat Events/Browser
722 * Trigger the load event of each matched element. This causes all of the functions
723 * that have been bound to thet load event to be executed.
725 * Marked as private: Calling load() without arguments throws exception because the ajax load
726 * does not handle it.
728 * @example $("p").load();
729 * @before <p onload="alert('Hello');">Hello</p>
730 * @result alert('Hello');
735 * @cat Events/Browser
739 * Bind a function to the load event of each matched element, which will only be executed once.
740 * Unlike a call to the normal .load() method, calling .oneload() causes the bound function to be
741 * only executed the first time it is triggered, and never again (unless it is re-bound).
743 * @example $("p").oneload( function() { alert("Hello"); } );
744 * @before <p onload="alert('Hello');">Hello</p>
745 * @result alert('Hello'); // Only executed for the first load
749 * @param Function fn A function to bind to the load event on each of the matched elements.
750 * @cat Events/Browser
754 * Removes a bound load event from each of the matched
755 * elements. You must pass the identical function that was used in the original
758 * @example $("p").unload( myFunction );
759 * @before <p onload="myFunction">Hello</p>
760 * @result <p>Hello</p>
764 * @param Function fn A function to unbind from the load event on each of the matched elements.
765 * @cat Events/Browser
769 * Removes all bound load events from each of the matched elements.
771 * @example $("p").unload();
772 * @before <p onload="alert('Hello');">Hello</p>
773 * @result <p>Hello</p>
777 * @cat Events/Browser
781 * Bind a function to the select event of each matched element.
783 * @example $("p").select( function() { alert("Hello"); } );
784 * @before <p>Hello</p>
785 * @result <p onselect="alert('Hello');">Hello</p>
789 * @param Function fn A function to bind to the select event on each of the matched elements.
794 * Trigger the select event of each matched element. This causes all of the functions
795 * that have been bound to thet select event to be executed.
797 * @example $("p").select();
798 * @before <p onselect="alert('Hello');">Hello</p>
799 * @result alert('Hello');
807 * Bind a function to the select event of each matched element, which will only be executed once.
808 * Unlike a call to the normal .select() method, calling .oneselect() causes the bound function to be
809 * only executed the first time it is triggered, and never again (unless it is re-bound).
811 * @example $("p").oneselect( function() { alert("Hello"); } );
812 * @before <p onselect="alert('Hello');">Hello</p>
813 * @result alert('Hello'); // Only executed for the first select
817 * @param Function fn A function to bind to the select event on each of the matched elements.
822 * Removes a bound select event from each of the matched
823 * elements. You must pass the identical function that was used in the original
826 * @example $("p").unselect( myFunction );
827 * @before <p onselect="myFunction">Hello</p>
828 * @result <p>Hello</p>
832 * @param Function fn A function to unbind from the select event on each of the matched elements.
837 * Removes all bound select events from each of the matched elements.
839 * @example $("p").unselect();
840 * @before <p onselect="alert('Hello');">Hello</p>
841 * @result <p>Hello</p>
849 * Bind a function to the mouseup event of each matched element.
851 * @example $("p").mouseup( function() { alert("Hello"); } );
852 * @before <p>Hello</p>
853 * @result <p onmouseup="alert('Hello');">Hello</p>
857 * @param Function fn A function to bind to the mouseup event on each of the matched elements.
862 * Trigger the mouseup event of each matched element. This causes all of the functions
863 * that have been bound to thet mouseup event to be executed.
865 * @example $("p").mouseup();
866 * @before <p onmouseup="alert('Hello');">Hello</p>
867 * @result alert('Hello');
875 * Bind a function to the mouseup event of each matched element, which will only be executed once.
876 * Unlike a call to the normal .mouseup() method, calling .onemouseup() causes the bound function to be
877 * only executed the first time it is triggered, and never again (unless it is re-bound).
879 * @example $("p").onemouseup( function() { alert("Hello"); } );
880 * @before <p onmouseup="alert('Hello');">Hello</p>
881 * @result alert('Hello'); // Only executed for the first mouseup
885 * @param Function fn A function to bind to the mouseup event on each of the matched elements.
890 * Removes a bound mouseup event from each of the matched
891 * elements. You must pass the identical function that was used in the original
894 * @example $("p").unmouseup( myFunction );
895 * @before <p onmouseup="myFunction">Hello</p>
896 * @result <p>Hello</p>
900 * @param Function fn A function to unbind from the mouseup event on each of the matched elements.
905 * Removes all bound mouseup events from each of the matched elements.
907 * @example $("p").unmouseup();
908 * @before <p onmouseup="alert('Hello');">Hello</p>
909 * @result <p>Hello</p>
917 * Bind a function to the unload event of each matched element.
919 * @example $("p").unload( function() { alert("Hello"); } );
920 * @before <p>Hello</p>
921 * @result <p onunload="alert('Hello');">Hello</p>
925 * @param Function fn A function to bind to the unload event on each of the matched elements.
926 * @cat Events/Browser
930 * Trigger the unload event of each matched element. This causes all of the functions
931 * that have been bound to thet unload event to be executed.
933 * @example $("p").unload();
934 * @before <p onunload="alert('Hello');">Hello</p>
935 * @result alert('Hello');
939 * @cat Events/Browser
943 * Bind a function to the unload event of each matched element, which will only be executed once.
944 * Unlike a call to the normal .unload() method, calling .oneunload() causes the bound function to be
945 * only executed the first time it is triggered, and never again (unless it is re-bound).
947 * @example $("p").oneunload( function() { alert("Hello"); } );
948 * @before <p onunload="alert('Hello');">Hello</p>
949 * @result alert('Hello'); // Only executed for the first unload
953 * @param Function fn A function to bind to the unload event on each of the matched elements.
954 * @cat Events/Browser
958 * Removes a bound unload event from each of the matched
959 * elements. You must pass the identical function that was used in the original
962 * @example $("p").ununload( myFunction );
963 * @before <p onunload="myFunction">Hello</p>
964 * @result <p>Hello</p>
968 * @param Function fn A function to unbind from the unload event on each of the matched elements.
969 * @cat Events/Browser
973 * Removes all bound unload events from each of the matched elements.
975 * @example $("p").ununload();
976 * @before <p onunload="alert('Hello');">Hello</p>
977 * @result <p>Hello</p>
981 * @cat Events/Browser
985 * Bind a function to the change event of each matched element.
987 * @example $("p").change( function() { alert("Hello"); } );
988 * @before <p>Hello</p>
989 * @result <p onchange="alert('Hello');">Hello</p>
993 * @param Function fn A function to bind to the change event on each of the matched elements.
998 * Trigger the change event of each matched element. This causes all of the functions
999 * that have been bound to thet change event to be executed.
1001 * @example $("p").change();
1002 * @before <p onchange="alert('Hello');">Hello</p>
1003 * @result alert('Hello');
1011 * Bind a function to the change event of each matched element, which will only be executed once.
1012 * Unlike a call to the normal .change() method, calling .onechange() causes the bound function to be
1013 * only executed the first time it is triggered, and never again (unless it is re-bound).
1015 * @example $("p").onechange( function() { alert("Hello"); } );
1016 * @before <p onchange="alert('Hello');">Hello</p>
1017 * @result alert('Hello'); // Only executed for the first change
1021 * @param Function fn A function to bind to the change event on each of the matched elements.
1026 * Removes a bound change event from each of the matched
1027 * elements. You must pass the identical function that was used in the original
1030 * @example $("p").unchange( myFunction );
1031 * @before <p onchange="myFunction">Hello</p>
1032 * @result <p>Hello</p>
1036 * @param Function fn A function to unbind from the change event on each of the matched elements.
1041 * Removes all bound change events from each of the matched elements.
1043 * @example $("p").unchange();
1044 * @before <p onchange="alert('Hello');">Hello</p>
1045 * @result <p>Hello</p>
1053 * Bind a function to the mouseout event of each matched element.
1055 * @example $("p").mouseout( function() { alert("Hello"); } );
1056 * @before <p>Hello</p>
1057 * @result <p onmouseout="alert('Hello');">Hello</p>
1061 * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1066 * Trigger the mouseout event of each matched element. This causes all of the functions
1067 * that have been bound to thet mouseout event to be executed.
1069 * @example $("p").mouseout();
1070 * @before <p onmouseout="alert('Hello');">Hello</p>
1071 * @result alert('Hello');
1079 * Bind a function to the mouseout event of each matched element, which will only be executed once.
1080 * Unlike a call to the normal .mouseout() method, calling .onemouseout() causes the bound function to be
1081 * only executed the first time it is triggered, and never again (unless it is re-bound).
1083 * @example $("p").onemouseout( function() { alert("Hello"); } );
1084 * @before <p onmouseout="alert('Hello');">Hello</p>
1085 * @result alert('Hello'); // Only executed for the first mouseout
1089 * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1094 * Removes a bound mouseout event from each of the matched
1095 * elements. You must pass the identical function that was used in the original
1098 * @example $("p").unmouseout( myFunction );
1099 * @before <p onmouseout="myFunction">Hello</p>
1100 * @result <p>Hello</p>
1104 * @param Function fn A function to unbind from the mouseout event on each of the matched elements.
1109 * Removes all bound mouseout events from each of the matched elements.
1111 * @example $("p").unmouseout();
1112 * @before <p onmouseout="alert('Hello');">Hello</p>
1113 * @result <p>Hello</p>
1121 * Bind a function to the keyup event of each matched element.
1123 * @example $("p").keyup( function() { alert("Hello"); } );
1124 * @before <p>Hello</p>
1125 * @result <p onkeyup="alert('Hello');">Hello</p>
1129 * @param Function fn A function to bind to the keyup event on each of the matched elements.
1130 * @cat Events/Keyboard
1134 * Trigger the keyup event of each matched element. This causes all of the functions
1135 * that have been bound to thet keyup event to be executed.
1137 * @example $("p").keyup();
1138 * @before <p onkeyup="alert('Hello');">Hello</p>
1139 * @result alert('Hello');
1143 * @cat Events/Keyboard
1147 * Bind a function to the keyup event of each matched element, which will only be executed once.
1148 * Unlike a call to the normal .keyup() method, calling .onekeyup() causes the bound function to be
1149 * only executed the first time it is triggered, and never again (unless it is re-bound).
1151 * @example $("p").onekeyup( function() { alert("Hello"); } );
1152 * @before <p onkeyup="alert('Hello');">Hello</p>
1153 * @result alert('Hello'); // Only executed for the first keyup
1157 * @param Function fn A function to bind to the keyup event on each of the matched elements.
1158 * @cat Events/Keyboard
1162 * Removes a bound keyup event from each of the matched
1163 * elements. You must pass the identical function that was used in the original
1166 * @example $("p").unkeyup( myFunction );
1167 * @before <p onkeyup="myFunction">Hello</p>
1168 * @result <p>Hello</p>
1172 * @param Function fn A function to unbind from the keyup event on each of the matched elements.
1173 * @cat Events/Keyboard
1177 * Removes all bound keyup events from each of the matched elements.
1179 * @example $("p").unkeyup();
1180 * @before <p onkeyup="alert('Hello');">Hello</p>
1181 * @result <p>Hello</p>
1185 * @cat Events/Keyboard
1189 * Bind a function to the click event of each matched element.
1191 * @example $("p").click( function() { alert("Hello"); } );
1192 * @before <p>Hello</p>
1193 * @result <p onclick="alert('Hello');">Hello</p>
1197 * @param Function fn A function to bind to the click event on each of the matched elements.
1202 * Trigger the click event of each matched element. This causes all of the functions
1203 * that have been bound to thet click event to be executed.
1205 * @example $("p").click();
1206 * @before <p onclick="alert('Hello');">Hello</p>
1207 * @result alert('Hello');
1215 * Bind a function to the click event of each matched element, which will only be executed once.
1216 * Unlike a call to the normal .click() method, calling .oneclick() causes the bound function to be
1217 * only executed the first time it is triggered, and never again (unless it is re-bound).
1219 * @example $("p").oneclick( function() { alert("Hello"); } );
1220 * @before <p onclick="alert('Hello');">Hello</p>
1221 * @result alert('Hello'); // Only executed for the first click
1225 * @param Function fn A function to bind to the click event on each of the matched elements.
1230 * Removes a bound click event from each of the matched
1231 * elements. You must pass the identical function that was used in the original
1234 * @example $("p").unclick( myFunction );
1235 * @before <p onclick="myFunction">Hello</p>
1236 * @result <p>Hello</p>
1240 * @param Function fn A function to unbind from the click event on each of the matched elements.
1245 * Removes all bound click events from each of the matched elements.
1247 * @example $("p").unclick();
1248 * @before <p onclick="alert('Hello');">Hello</p>
1249 * @result <p>Hello</p>
1257 * Bind a function to the resize event of each matched element.
1259 * @example $("p").resize( function() { alert("Hello"); } );
1260 * @before <p>Hello</p>
1261 * @result <p onresize="alert('Hello');">Hello</p>
1265 * @param Function fn A function to bind to the resize event on each of the matched elements.
1266 * @cat Events/Browser
1270 * Trigger the resize event of each matched element. This causes all of the functions
1271 * that have been bound to thet resize event to be executed.
1273 * @example $("p").resize();
1274 * @before <p onresize="alert('Hello');">Hello</p>
1275 * @result alert('Hello');
1279 * @cat Events/Browser
1283 * Bind a function to the resize event of each matched element, which will only be executed once.
1284 * Unlike a call to the normal .resize() method, calling .oneresize() causes the bound function to be
1285 * only executed the first time it is triggered, and never again (unless it is re-bound).
1287 * @example $("p").oneresize( function() { alert("Hello"); } );
1288 * @before <p onresize="alert('Hello');">Hello</p>
1289 * @result alert('Hello'); // Only executed for the first resize
1293 * @param Function fn A function to bind to the resize event on each of the matched elements.
1294 * @cat Events/Browser
1298 * Removes a bound resize event from each of the matched
1299 * elements. You must pass the identical function that was used in the original
1302 * @example $("p").unresize( myFunction );
1303 * @before <p onresize="myFunction">Hello</p>
1304 * @result <p>Hello</p>
1308 * @param Function fn A function to unbind from the resize event on each of the matched elements.
1309 * @cat Events/Browser
1313 * Removes all bound resize events from each of the matched elements.
1315 * @example $("p").unresize();
1316 * @before <p onresize="alert('Hello');">Hello</p>
1317 * @result <p>Hello</p>
1321 * @cat Events/Browser
1325 * Bind a function to the mousemove event of each matched element.
1327 * @example $("p").mousemove( function() { alert("Hello"); } );
1328 * @before <p>Hello</p>
1329 * @result <p onmousemove="alert('Hello');">Hello</p>
1333 * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1338 * Trigger the mousemove event of each matched element. This causes all of the functions
1339 * that have been bound to thet mousemove event to be executed.
1341 * @example $("p").mousemove();
1342 * @before <p onmousemove="alert('Hello');">Hello</p>
1343 * @result alert('Hello');
1351 * Bind a function to the mousemove event of each matched element, which will only be executed once.
1352 * Unlike a call to the normal .mousemove() method, calling .onemousemove() causes the bound function to be
1353 * only executed the first time it is triggered, and never again (unless it is re-bound).
1355 * @example $("p").onemousemove( function() { alert("Hello"); } );
1356 * @before <p onmousemove="alert('Hello');">Hello</p>
1357 * @result alert('Hello'); // Only executed for the first mousemove
1359 * @name onemousemove
1361 * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1366 * Removes a bound mousemove event from each of the matched
1367 * elements. You must pass the identical function that was used in the original
1370 * @example $("p").unmousemove( myFunction );
1371 * @before <p onmousemove="myFunction">Hello</p>
1372 * @result <p>Hello</p>
1376 * @param Function fn A function to unbind from the mousemove event on each of the matched elements.
1381 * Removes all bound mousemove events from each of the matched elements.
1383 * @example $("p").unmousemove();
1384 * @before <p onmousemove="alert('Hello');">Hello</p>
1385 * @result <p>Hello</p>
1393 * Bind a function to the mousedown event of each matched element.
1395 * @example $("p").mousedown( function() { alert("Hello"); } );
1396 * @before <p>Hello</p>
1397 * @result <p onmousedown="alert('Hello');">Hello</p>
1401 * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1406 * Trigger the mousedown event of each matched element. This causes all of the functions
1407 * that have been bound to thet mousedown event to be executed.
1409 * @example $("p").mousedown();
1410 * @before <p onmousedown="alert('Hello');">Hello</p>
1411 * @result alert('Hello');
1419 * Bind a function to the mousedown event of each matched element, which will only be executed once.
1420 * Unlike a call to the normal .mousedown() method, calling .onemousedown() causes the bound function to be
1421 * only executed the first time it is triggered, and never again (unless it is re-bound).
1423 * @example $("p").onemousedown( function() { alert("Hello"); } );
1424 * @before <p onmousedown="alert('Hello');">Hello</p>
1425 * @result alert('Hello'); // Only executed for the first mousedown
1427 * @name onemousedown
1429 * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1434 * Removes a bound mousedown event from each of the matched
1435 * elements. You must pass the identical function that was used in the original
1438 * @example $("p").unmousedown( myFunction );
1439 * @before <p onmousedown="myFunction">Hello</p>
1440 * @result <p>Hello</p>
1444 * @param Function fn A function to unbind from the mousedown event on each of the matched elements.
1449 * Removes all bound mousedown events from each of the matched elements.
1451 * @example $("p").unmousedown();
1452 * @before <p onmousedown="alert('Hello');">Hello</p>
1453 * @result <p>Hello</p>
1461 * Bind a function to the mouseover event of each matched element.
1463 * @example $("p").mouseover( function() { alert("Hello"); } );
1464 * @before <p>Hello</p>
1465 * @result <p onmouseover="alert('Hello');">Hello</p>
1469 * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1474 * Trigger the mouseover event of each matched element. This causes all of the functions
1475 * that have been bound to thet mousedown event to be executed.
1477 * @example $("p").mouseover();
1478 * @before <p onmouseover="alert('Hello');">Hello</p>
1479 * @result alert('Hello');
1487 * Bind a function to the mouseover event of each matched element, which will only be executed once.
1488 * Unlike a call to the normal .mouseover() method, calling .onemouseover() causes the bound function to be
1489 * only executed the first time it is triggered, and never again (unless it is re-bound).
1491 * @example $("p").onemouseover( function() { alert("Hello"); } );
1492 * @before <p onmouseover="alert('Hello');">Hello</p>
1493 * @result alert('Hello'); // Only executed for the first mouseover
1495 * @name onemouseover
1497 * @param Function fn A function to bind to the mouseover event on each of the matched elements.
1502 * Removes a bound mouseover event from each of the matched
1503 * elements. You must pass the identical function that was used in the original
1506 * @example $("p").unmouseover( myFunction );
1507 * @before <p onmouseover="myFunction">Hello</p>
1508 * @result <p>Hello</p>
1512 * @param Function fn A function to unbind from the mouseover event on each of the matched elements.
1517 * Removes all bound mouseover events from each of the matched elements.
1519 * @example $("p").unmouseover();
1520 * @before <p onmouseover="alert('Hello');">Hello</p>
1521 * @result <p>Hello</p>
1528 var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1529 "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
1530 "submit,keydown,keypress,keyup,error").split(",");
1532 // Go through all the event names, but make sure that
1533 // it is enclosed properly
1534 for ( var i = 0; i < e.length; i++ ) new function(){
1538 // Handle event binding
1539 jQuery.fn[o] = function(f){
1540 return f ? this.bind(o, f) : this.trigger(o);
1543 // Handle event unbinding
1544 jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
1546 // Finally, handle events that only fire once
1547 jQuery.fn["one"+o] = function(f){
1548 // save cloned reference to this
1549 var element = jQuery(this);
1550 var handler = function() {
1551 // unbind itself when executed
1552 element.unbind(o, handler);
1554 // apply original handler with the same arguments
1555 return f.apply(this, arguments);
1557 return this.bind(o, handler);
1562 // If Mozilla is used
1563 if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
1564 // Use the handy event callback
1565 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
1567 // If IE is used, use the excellent hack by Matthias Miller
1568 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1569 } else if ( jQuery.browser.msie ) {
1571 // Only works if you document.write() it
1572 document.write("<scr" + "ipt id=__ie_init defer=true " +
1573 "src=//:><\/script>");
1575 // Use the defer script hack
1576 var script = document.getElementById("__ie_init");
1577 if (script) // script does not exist if jQuery is loaded dynamically
1578 script.onreadystatechange = function() {
1579 if ( this.readyState != "complete" ) return;
1580 this.parentNode.removeChild( this );
1584 // Clear from memory
1587 // If Safari is used
1588 } else if ( jQuery.browser.safari ) {
1589 // Continually check to see if the document.readyState is valid
1590 jQuery.safariTimer = setInterval(function(){
1591 // loaded and complete are both valid states
1592 if ( document.readyState == "loaded" ||
1593 document.readyState == "complete" ) {
1595 // If either one are found, remove the timer
1596 clearInterval( jQuery.safariTimer );
1597 jQuery.safariTimer = null;
1599 // and execute any waiting functions
1605 // A fallback to window.onload, that will always work
1606 jQuery.event.add( window, "load", jQuery.ready );
1610 // Clean up after IE to avoid memory leaks
1611 if (jQuery.browser.msie) jQuery(window).unload(function() {
1612 var event = jQuery.event, global = event.global;
1613 for (var type in global) {
1614 var els = global[type], i = els.length;
1615 if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i);