diff --git a/entries/ajaxComplete-shorthand.xml b/entries/ajaxComplete-shorthand.xml new file mode 100644 index 00000000..73d766d5 --- /dev/null +++ b/entries/ajaxComplete-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxComplete() + Register a handler to be called when Ajax requests complete. This is an AjaxEvent. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxComplete", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxComplete.xml b/entries/ajaxComplete.xml index f96dc4cf..168865e7 100644 --- a/entries/ajaxComplete.xml +++ b/entries/ajaxComplete.xml @@ -1,8 +1,12 @@ - - .ajaxComplete() + + ajaxComplete event + Register a handler to be called when Ajax requests complete. This is an AjaxEvent. - 1.0 + 1.7 + + The string "ajaxComplete". + @@ -10,9 +14,11 @@ The function to be invoked. - Register a handler to be called when Ajax requests complete. This is an AjaxEvent. -

Whenever an Ajax request completes, jQuery triggers the ajaxComplete event. Any and all handlers that have been registered with the .ajaxComplete() method are executed at this time.

+
+

This page describes the ajaxComplete event. For the deprecated .ajaxComplete() method, see .ajaxComplete().

+
+

Whenever an Ajax request completes, jQuery triggers the ajaxComplete event. Any and all registered ajaxComplete handlers are executed at this time.

To observe this method in action, set up a basic Ajax load request:


 <div class="trigger">Trigger</div>
@@ -21,38 +27,39 @@
     

Attach the event handler to the document:


-$( document ).ajaxComplete(function() {
+$( document ).on( "ajaxComplete", function() {
   $( ".log" ).text( "Triggered ajaxComplete handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


-$( ".trigger" ).click(function() {
+$( ".trigger)" ).on( "click", function() {
   $( ".result" ).load( "ajax/test.html" );
-});
+} );
     

When the user clicks the element with class trigger and the Ajax request completes, the log message is displayed.

All ajaxComplete handlers are invoked, regardless of what Ajax request was completed. If you must differentiate between the requests, use the parameters passed to the handler. Each time an ajaxComplete handler is executed, it is passed the event object, the XMLHttpRequest object, and the settings object that was used in the creation of the request. For example, you can restrict the callback to only handling events dealing with a particular URL:


-$( document ).ajaxComplete(function( event, xhr, settings ) {
+$( document ).on( "ajaxComplete", function( event, xhr, settings ) {
   if ( settings.url === "ajax/test.html" ) {
     $( ".log" ).text( "Triggered ajaxComplete handler. The result is " +
       xhr.responseText );
   }
-});
+} );
     

Note: You can get the returned Ajax contents by looking at xhr.responseText.

- - + + Show a message when an Ajax request completes. +
diff --git a/entries/ajaxError-shorthand.xml b/entries/ajaxError-shorthand.xml new file mode 100644 index 00000000..c1a306bd --- /dev/null +++ b/entries/ajaxError-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxError() + Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxError", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxError.xml b/entries/ajaxError.xml index 19abee09..d18cf977 100644 --- a/entries/ajaxError.xml +++ b/entries/ajaxError.xml @@ -1,8 +1,12 @@ - - .ajaxError() + + ajaxError event + Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. - 1.0 + 1.7 + + The string "ajaxError". + The function to be invoked. @@ -11,9 +15,11 @@ - Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. -

Whenever an Ajax request completes with an error, jQuery triggers the ajaxError event. Any and all handlers that have been registered with the .ajaxError() method are executed at this time. Note: This handler is not called for cross-domain script and cross-domain JSONP requests.

+
+

This page describes the ajaxError event. For the deprecated .ajaxError() method, see .ajaxError().

+
+

Whenever an Ajax request completes with an error, jQuery triggers the ajaxError event. Any and all registered ajaxError handlers are executed at this time. Note: This handler is not called for cross-domain script and cross-domain JSONP requests.

To observe this method in action, set up a basic Ajax load request.


 <button class="trigger">Trigger</button>
@@ -22,35 +28,37 @@
     

Attach the event handler to the document:


-$( document ).ajaxError(function() {
+$( document ).on( "ajaxError", function() {
   $( ".log" ).text( "Triggered ajaxError handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


 $( "button.trigger" ).on( "click", function() {
   $( "div.result" ).load( "ajax/missing.html" );
-});
+} );
     

When the user clicks the button and the Ajax request fails, because the requested file is missing, the log message is displayed.

All ajaxError handlers are invoked, regardless of what Ajax request was completed. To differentiate between the requests, use the parameters passed to the handler. Each time an ajaxError handler is executed, it is passed the event object, the jqXHR object (prior to jQuery 1.5, the XHR object), and the settings object that was used in the creation of the request. When an HTTP error occurs, the fourth argument (thrownError) receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." For example, to restrict the error callback to only handling events dealing with a particular URL:


-$( document ).ajaxError(function( event, jqxhr, settings, thrownError ) {
+$( document ).on( "ajaxError", function( event, jqxhr, settings, thrownError ) {
   if ( settings.url == "ajax/missing.html" ) {
     $( "div.log" ).text( "Triggered ajaxError handler." );
   }
-});
+} ); +
- - + + Show a message when an Ajax request fails. +
diff --git a/entries/ajaxSend-shorthand.xml b/entries/ajaxSend-shorthand.xml new file mode 100644 index 00000000..4c1dc9cc --- /dev/null +++ b/entries/ajaxSend-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxSend() + Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxSend", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxSend.xml b/entries/ajaxSend.xml index db814fee..ad01194e 100644 --- a/entries/ajaxSend.xml +++ b/entries/ajaxSend.xml @@ -1,8 +1,12 @@ - - .ajaxSend() + + ajaxSend event + Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. - 1.0 + 1.7 + + The string "ajaxSend". + The function to be invoked. @@ -10,9 +14,11 @@ - Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. -

Whenever an Ajax request is about to be sent, jQuery triggers the ajaxSend event. Any and all handlers that have been registered with the .ajaxSend() method are executed at this time.

+
+

This page describes the ajaxSend event. For the deprecated .ajaxSend() method, see .ajaxSend().

+
+

Whenever an Ajax request is about to be sent, jQuery triggers the ajaxSend event. Any and all registerd ajaxSend handlers are executed at this time.

To observe this method in action, set up a basic Ajax load request:


 <div class="trigger">Trigger</div>
@@ -21,36 +27,37 @@
     

Attach the event handler to the document:


-$( document ).ajaxSend(function() {
+$( document ).on( "ajaxSend", function() {
   $( ".log" ).text( "Triggered ajaxSend handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


-$( ".trigger" ).click(function() {
+$( ".trigger)" ).on( "click", function() {
   $( ".result" ).load( "ajax/test.html" );
-});
+} );
     

When the user clicks the element with class trigger and the Ajax request is about to begin, the log message is displayed.

All ajaxSend handlers are invoked, regardless of what Ajax request is to be sent. If you must differentiate between the requests, use the parameters passed to the handler. Each time an ajaxSend handler is executed, it is passed the event object, the jqXHR object (in version 1.4, XMLHttpRequestobject), and the settings object that was used in the creation of the Ajax request. For example, you can restrict the callback to only handling events dealing with a particular URL:


-$( document ).ajaxSend(function( event, jqxhr, settings ) {
+$( document ).on( "ajaxSend", function( event, jqxhr, settings ) {
   if ( settings.url == "ajax/test.html" ) {
     $( ".log" ).text( "Triggered ajaxSend handler." );
   }
-});
+} );
     
- - + + Show a message before an Ajax request is sent. +
diff --git a/entries/ajaxStart-shorthand.xml b/entries/ajaxStart-shorthand.xml new file mode 100644 index 00000000..41c7c71a --- /dev/null +++ b/entries/ajaxStart-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxStart() + Register a handler to be called when the first Ajax request begins. This is an Ajax Event. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxStart", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxStart.xml b/entries/ajaxStart.xml index bf7fc14a..3d8f4df4 100644 --- a/entries/ajaxStart.xml +++ b/entries/ajaxStart.xml @@ -1,15 +1,21 @@ - - .ajaxStart() + + ajaxStart event + Register a handler to be called when the first Ajax request begins. This is an Ajax Event. - 1.0 + 1.7 + + The string "ajaxStart". + The function to be invoked. - Register a handler to be called when the first Ajax request begins. This is an Ajax Event. -

Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the ajaxStart event. Any and all handlers that have been registered with the .ajaxStart() method are executed at this time.

+
+

This page describes the ajaxStart event. For the deprecated .ajaxStart() method, see .ajaxStart().

+
+

Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the ajaxStart event. Any and all handlers that have been registered with .on( "ajaxStart", ... ) are executed at this time.

To observe this method in action, set up a basic Ajax load request:


 <div class="trigger">Trigger</div>
@@ -18,28 +24,29 @@
     

Attach the event handler to any element:


-$( document ).ajaxStart(function() {
+$( document ).on( "ajaxStart", function() {
   $( ".log" ).text( "Triggered ajaxStart handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


-$( ".trigger" ).click(function() {
+$( ".trigger" ).on( "click", function() {
   $( ".result" ).load( "ajax/test.html" );
-});
+} );
     

When the user clicks the element with class trigger and the Ajax request is sent, the log message is displayed.

- - + + Show a loading message whenever an Ajax request starts (and none is already active). +
diff --git a/entries/ajaxStop-shorthand.xml b/entries/ajaxStop-shorthand.xml new file mode 100644 index 00000000..e4b5ab83 --- /dev/null +++ b/entries/ajaxStop-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxStop() + Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxStop", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxStop.xml b/entries/ajaxStop.xml index 073dd208..f42c7444 100644 --- a/entries/ajaxStop.xml +++ b/entries/ajaxStop.xml @@ -1,15 +1,21 @@ - - .ajaxStop() + + ajaxStop event Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. - 1.0 + 1.7 + + The string "ajaxStop". + The function to be invoked. -

Whenever an Ajax request completes, jQuery checks whether there are any other outstanding Ajax requests. If none remain, jQuery triggers the ajaxStop event. Any and all handlers that have been registered with the .ajaxStop() method are executed at this time. The ajaxStop event is also triggered if the last outstanding Ajax request is cancelled by returning false within the beforeSend callback function.

+
+

This page describes the ajaxStop event. For the deprecated .ajaxStop() method, see .ajaxStop().

+
+

Whenever an Ajax request completes, jQuery checks whether there are any other outstanding Ajax requests. If none remain, jQuery triggers the ajaxStop event. Any and all registered ajaxStop handlers are executed at this time. The ajaxStop event is also triggered if the last outstanding Ajax request is cancelled by returning false within the beforeSend callback function.

To observe this method in action, set up a basic Ajax load request:


 <div class="trigger">Trigger</div>
@@ -18,28 +24,29 @@
     

Attach the event handler to the document:


-$( document ).ajaxStop(function() {
+$( document ).on( "ajaxStop", function() {
   $( ".log" ).text( "Triggered ajaxStop handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


-$( ".trigger" ).click(function() {
+$( ".trigger" ).on( "click", function() {
   $( ".result" ).load( "ajax/test.html" );
-});
+} );
     

When the user clicks the element with class trigger and the Ajax request completes, the log message is displayed.

- - + + Hide a loading message after all the Ajax requests have stopped. +
diff --git a/entries/ajaxSuccess-shorthand.xml b/entries/ajaxSuccess-shorthand.xml new file mode 100644 index 00000000..358b5ff5 --- /dev/null +++ b/entries/ajaxSuccess-shorthand.xml @@ -0,0 +1,19 @@ + + + .ajaxSuccess() + Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. + + 1.0 + + The function to be invoked. + + + +
+

This API is deprecated. Use .on( "ajaxSuccess", handler ) instead.

+
+
+ + + +
diff --git a/entries/ajaxSuccess.xml b/entries/ajaxSuccess.xml index 840ec028..e92a1269 100644 --- a/entries/ajaxSuccess.xml +++ b/entries/ajaxSuccess.xml @@ -1,8 +1,12 @@ - - .ajaxSuccess() + + ajaxSuccess event + Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. - 1.0 + 1.7 + + The string "ajaxSuccess". + The function to be invoked. @@ -11,9 +15,11 @@ - Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. -

Whenever an Ajax request completes successfully, jQuery triggers the ajaxSuccess event. Any and all handlers that have been registered with the .ajaxSuccess() method are executed at this time.

+
+

This page describes the ajaxSuccess event. For the deprecated .ajaxSuccess() method, see .ajaxSuccess().

+
+

Whenever an Ajax request completes successfully, jQuery triggers the ajaxSuccess event. Any and all registered ajaxSuccess handlers are executed at this time.

To observe this method in action, set up a basic Ajax load request:


 <div class="trigger">Trigger</div>
@@ -22,38 +28,39 @@
     

Attach the event handler to any element:


-$(document).ajaxSuccess(function() {
+$( document ).on( "ajaxSuccess", function() {
   $( ".log" ).text( "Triggered ajaxSuccess handler." );
-});
+} );
     

Now, make an Ajax request using any jQuery method:


 $( ".trigger" ).on( "click", function() {
   $( ".result" ).load( "ajax/test.html" );
-});
+} );
     

When the user clicks the element with class trigger and the Ajax request completes successfully, the log message is displayed.

All ajaxSuccess handlers are invoked, regardless of what Ajax request was completed. If you must differentiate between the requests, you can use the parameters passed to the handler. Each time an ajaxSuccess handler is executed, it is passed the event object, the XMLHttpRequest object, and the settings object that was used in the creation of the request. For example, you can restrict the callback to only handling events dealing with a particular URL:


-$( document ).ajaxSuccess(function( event, xhr, settings ) {
+$( document ).on( "ajaxSuccess", function( event, xhr, settings ) {
   if ( settings.url == "ajax/test.html" ) {
     $( ".log" ).text( "Triggered ajaxSuccess handler. The Ajax response was: " +
       xhr.responseText );
   }
-});
+} );
     

Note: You can get the returned Ajax contents by looking at xhr.responseXML or xhr.responseText for xml and html respectively.

- - + + Show a message when an Ajax request completes successfully. +
diff --git a/entries/animate.xml b/entries/animate.xml index 57af4823..1ece251c 100644 --- a/entries/animate.xml +++ b/entries/animate.xml @@ -45,7 +45,7 @@

To animate the opacity, left offset, and height of the image simultaneously:


-$( "#clickme" ).click(function() {
+$( "#clickme)" ).on( "click", function() {
   $( "#book" ).animate({
     opacity: 0.25,
     left: "+=50",
@@ -101,7 +101,7 @@ $( "li" ).animate({
     

As of jQuery version 1.4, you can set per-property easing functions within a single .animate() call. In the first version of .animate(), each property can take an array as its value: The first member of the array is the CSS property and the second member is an easing function. If a per-property easing function is not defined for a particular property, it uses the value of the .animate() method's optional easing argument. If the easing argument is not defined, the default swing function is used.

For example, to simultaneously animate the width and height with the swing easing function and the opacity with the linear easing function:


-$( "#clickme" ).click(function() {
+$( "#clickme)" ).on( "click", function() {
   $( "#book" ).animate({
     width: [ "toggle", "swing" ],
     height: [ "toggle", "swing" ],
@@ -113,7 +113,7 @@ $( "#clickme" ).click(function() {
     

In the second version of .animate(), the options object can include the specialEasing property, which is itself an object of CSS properties and their corresponding easing functions. For example, to simultaneously animate the width using the linear easing function and the height using the easeOutBounce easing function:


-$( "#clickme" ).click(function() {
+$( "#clickme)" ).on( "click", function() {
   $( "#book" ).animate({
     width: "toggle",
     height: "toggle"
@@ -137,7 +137,7 @@ $( "#clickme" ).click(function() {
     
@@ -191,7 +191,7 @@ $( "#left" ).click(function(){
 
 The second button starts a traditional chained animation, where each animation will start once the previous animation on the element has completed.
     
       
diff --git a/entries/blur-shorthand.xml b/entries/blur-shorthand.xml
new file mode 100644
index 00000000..589a1ceb
--- /dev/null
+++ b/entries/blur-shorthand.xml
@@ -0,0 +1,37 @@
+
+
+  .blur()
+  Bind an event handler to the "blur" event, or trigger that event on an element.
+  
+    1.0
+    
+      A function to execute each time the event is triggered.
+      
+    
+  
+  
+    1.4.3
+    
+      An object containing data that will be passed to the event handler.
+    
+    
+      A function to execute each time the event is triggered.
+      
+    
+  
+  
+    1.0
+  
+  
+    
+

This API is deprecated.

+

Instead of .blur( handler ) or .blur( eventData, handler ), use .on( "blur", handler ) or .on( "blur", eventData, handler ), respectively.

+

Instead of .blur(), use .trigger( "blur" ).

+
+
+ + + + + +
diff --git a/entries/blur.xml b/entries/blur.xml index 11afbd6a..d99003e9 100644 --- a/entries/blur.xml +++ b/entries/blur.xml @@ -1,16 +1,15 @@ - - .blur() - Bind an event handler to the "blur" JavaScript event, or trigger that event on an element. + + +Bind an event handler to the "blur" event, or trigger that event on an element. + + blur event + Bind an event handler to the "blur" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "blur". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -19,11 +18,10 @@ - - 1.0 - -

This method is a shortcut for .on( "blur", handler ) in the first two variations, and .trigger( "blur" ) in the third.

+
+

This page describes the blur event. For the deprecated .blur() method, see .blur().

+

The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as <input>. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.

For example, consider the HTML:


@@ -34,33 +32,53 @@
 <div id="other">
   Trigger the handler
 </div>
-The event handler can be bound to the first input field:
-$( "#target" ).blur(function() {
-  alert( "Handler for .blur() called." );
-});
+    
+

The event handler can be bound to the first input field:

+

+$( "#target" ).on( "blur", function() {
+  alert( "Handler for `blur` called." );
+} );
     

Now if the first field has the focus, clicking elsewhere or tabbing away from it displays the alert:

- Handler for .blur() called. + Handler for `blur` called.

-

To trigger the event programmatically, apply .blur() without an argument:

+

To trigger the event programmatically, call .trigger( "blur" ):


-$( "#other" ).click(function() {
-  $( "#target" ).blur();
-});
+$( "#other" ).on( "click", function() {
+  $( "#target" ).trigger( "blur" );
+} );
     

After this code executes, clicks on Trigger the handler will also alert the message.

-

The blur event does not bubble in Internet Explorer. Therefore, scripts that rely on event delegation with the blur event will not work consistently across browsers. As of version 1.4.2, however, jQuery works around this limitation by mapping blur to the focusout event in its event delegation methods, .live() and .delegate().

+

The blur event does not bubble. As of version 1.4.2, jQuery works around this limitation by mapping blur to the focusout event in its event delegation methods.

- To trigger the blur event on all paragraphs: - + +
+ + + blur event + Trigger the "blur" event on an element. + + 1.0 + + The string "blur". + + + +

See the description for .on( "blur", ... ).

+
+ + +
+ +
diff --git a/entries/button-selector.xml b/entries/button-selector.xml index 858522e5..12c8471c 100644 --- a/entries/button-selector.xml +++ b/entries/button-selector.xml @@ -16,9 +16,9 @@ var input = $( ":button" ).addClass( "marked" ); $( "div" ).text( "For this type jQuery found " + input.length + "." ); // Prevent the form from submitting -$( "form" ).submit(function( event ) { +$( "form" ).on( "submit", function( event ) { event.preventDefault(); -}); +} ); ]]>
- + + + + + change event + Trigger the "change" event on an element. + + 1.0 + + The string "change". + + + +

See the description for .on( "change", ... ).

+
+ +
+ + diff --git a/entries/checkbox-selector.xml b/entries/checkbox-selector.xml index 843cdaf7..ba0fd815 100644 --- a/entries/checkbox-selector.xml +++ b/entries/checkbox-selector.xml @@ -26,9 +26,9 @@ $( "div" ) .css( "color", "red" ); // Prevent the form from submitting -$( "form" ).submit(function( event ) { +$( "form" ).on( "submit", function( event ) { event.preventDefault(); -}); +} ); ]]> - Trigger the click event on all of the paragraphs on the page: + Trigger the click event on all the paragraphs on the page: - + + + + + click event + Trigger the "click" event on an element. + + 1.0 + + The string "click". + + + +

See the description for .on( "click", ... ).

+
+ +
+ + diff --git a/entries/contextmenu-shorthand.xml b/entries/contextmenu-shorthand.xml new file mode 100644 index 00000000..9b1f4873 --- /dev/null +++ b/entries/contextmenu-shorthand.xml @@ -0,0 +1,36 @@ + + + .contextmenu() + Bind an event handler to the "contextmenu" event, or trigger that event on an element. + + 1.0 + + A function to execute each time the event is triggered. + + + + + 1.4.3 + + An object containing data that will be passed to the event handler. + + + A function to execute each time the event is triggered. + + + + + 1.0 + + +
+

This API is deprecated.

+

Instead of .contextmenu( handler ) or .contextmenu( eventData, handler ), use .on( "contextmenu", handler ) or .on( "contextmenu", eventData, handler ), respectively.

+

Instead of .contextmenu(), use .trigger( "contextmenu" ).

+
+
+ + + + +
diff --git a/entries/contextmenu.xml b/entries/contextmenu.xml index 9849f7e9..63d9c179 100644 --- a/entries/contextmenu.xml +++ b/entries/contextmenu.xml @@ -1,7 +1,10 @@ - - .contextmenu() - Bind an event handler to the "contextmenu" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "contextmenu" event, or trigger that event on an element. + + + contextmenu event + Bind an event handler to the "contextmenu" event. 1.0 @@ -19,12 +22,11 @@ - - 1.0 - -

This method is a shortcut for .on( "contextmenu", handler ) in the first two variations, and .trigger( "contextmenu" ) in the third. - The contextmenu event is sent to an element when the right button of the mouse is clicked on it, but before the context menu is displayed. In case the context menu key is pressed, the event is triggered on the html element or the currently focused element. Any HTML element can receive this event. +

+

This page describes the contextmenu event. For the deprecated .contextmenu() method, see .contextmenu().

+
+

The contextmenu event is sent to an element when the right button of the mouse is clicked on it, but before the context menu is displayed. In case the context menu key is pressed, the event is triggered on the html element or the currently focused element. Any HTML element can receive this event. For example, consider the HTML:


 <div id="target">
@@ -33,35 +35,34 @@
     

The event handler can be bound to the <div> as follows:


-$( "#target" ).contextmenu(function() {
-  alert( "Handler for .contextmenu() called." );
-});
+$( "#target" ).on( "contextmenu", function() {
+  alert( "Handler for `contextmenu` called." );
+} );
     

Now right-clicking on this element displays the alert:

- Handler for .contextmenu() called. + Handler for `contextmenu` called.

-

To trigger the event manually, call .contextmenu() without an argument:

+

To trigger the event manually, use .trigger( "contextmenu" ):


-$( "#target" ).contextmenu();
+$( "#target" ).trigger( "contextmenu" );
     
- To show a "Hello World!" alert box when the contextmenu event is triggered on a paragraph on the page: Right click to toggle background color. Get the data named "blah" stored at for an element. Double click to toggle background color. diff --git a/entries/dequeue.xml b/entries/dequeue.xml index 7caca4e3..24f89c3a 100644 --- a/entries/dequeue.xml +++ b/entries/dequeue.xml @@ -14,7 +14,7 @@ Use dequeue to end a custom queue function which allows the queue to keep going. - - - + +
+ + + error event + Trigger the "error" event on an element. + + 1.0 + + The string "error". + + + +

See the description for .on( "error", ... ).

+
+ +
+ +
diff --git a/entries/event.currentTarget.xml b/entries/event.currentTarget.xml index f70a8626..859cb8d4 100644 --- a/entries/event.currentTarget.xml +++ b/entries/event.currentTarget.xml @@ -14,11 +14,11 @@ Alert that currentTarget matches the `this` keyword. -
\ No newline at end of file + diff --git a/entries/event.isDefaultPrevented.xml b/entries/event.isDefaultPrevented.xml index 676b31f3..d9ada314 100644 --- a/entries/event.isDefaultPrevented.xml +++ b/entries/event.isDefaultPrevented.xml @@ -9,7 +9,7 @@ Checks whether event.preventDefault() was called. diff --git a/entries/event.namespace.xml b/entries/event.namespace.xml index ed661c92..bbebcda4 100644 --- a/entries/event.namespace.xml +++ b/entries/event.namespace.xml @@ -14,7 +14,7 @@ $( "p" ).on( "test.something", function( event ) { alert( event.namespace ); }); -$( "button" ).click(function( event ) { +$( "button" ).on( "click", function( event ) { $( "p" ).trigger( "test.something" ); }); ]]> diff --git a/entries/event.preventDefault.xml b/entries/event.preventDefault.xml index ac534fcb..82b4e104 100644 --- a/entries/event.preventDefault.xml +++ b/entries/event.preventDefault.xml @@ -11,7 +11,7 @@ Cancel the default action (navigation) of the click. diff --git a/entries/event.result.xml b/entries/event.result.xml index fa5cd9ad..40bd1872 100644 --- a/entries/event.result.xml +++ b/entries/event.result.xml @@ -11,10 +11,10 @@ Display previous handler's return value diff --git a/entries/event.stopImmediatePropagation.xml b/entries/event.stopImmediatePropagation.xml index e5b53eba..dd86bd7c 100644 --- a/entries/event.stopImmediatePropagation.xml +++ b/entries/event.stopImmediatePropagation.xml @@ -25,14 +25,14 @@ } ]]>
@@ -40,7 +40,7 @@ function handler( event ) { target.children().toggle(); } } -$( "ul" ).click( handler ).find( "ul" ).hide(); +$( "ul" ).on( "click", handler ).find( "ul" ).hide(); ]]>
diff --git a/entries/fadeIn.xml b/entries/fadeIn.xml index a73fdc06..4af0872f 100644 --- a/entries/fadeIn.xml +++ b/entries/fadeIn.xml @@ -29,7 +29,7 @@ <img id="book" src="book.png" alt="" width="100" height="123"> // With the element initially hidden, we can show it slowly: -$( "#clickme" ).click(function() { +$( "#clickme)" ).on( "click", function() { $( "#book" ).fadeIn( "slow", function() { // Animation complete }); @@ -52,9 +52,9 @@ $( "#clickme" ).click(function() { Animates hidden divs to fade in one by one, completing each animation within 600 milliseconds. @@ -76,7 +76,7 @@ $( "p" ).click(function() { Fades out spans in one section that you click on. @@ -131,23 +131,23 @@ $( "p" ).each(function( n ) { $( this ).text( $( "p" ).eq( r ).text() ); $( "p" ).eq( r ).text( tmp ); $( this ).css( "left", getPos( n ) ); -}); +} ); $( "div" ) .each(function( n ) { $( this ).css( "left", getPos( n ) ); - }) + } ) .css( "cursor", "pointer" ) - .click( function() { + .on( "click", function() { $( this ).fadeTo( 250, 0.25, function() { $( this ) .css( "cursor", "" ) .prev() - .css({ + .css( { "font-weight": "bolder", "font-style": "italic" - }); - }); - }); + } ); + } ); + } ); ]]> To focus on a login input box with id 'login' on page startup, try: - + + + + + focus event + Trigger the "focus" event on an element. + + 1.0 + + The string "focus". + + + +

See the description for .on( "focus", ... ).

+
+ + +
+ + diff --git a/entries/focusin-shorthand.xml b/entries/focusin-shorthand.xml new file mode 100644 index 00000000..ff8f548e --- /dev/null +++ b/entries/focusin-shorthand.xml @@ -0,0 +1,37 @@ + + + .focusin() + Bind an event handler to the "focusin" event, or trigger that event on an element. + + 1.0 + + A function to execute each time the event is triggered. + + + + + 1.4.3 + + An object containing data that will be passed to the event handler. + + + A function to execute each time the event is triggered. + + + + + 1.0 + + +
+

This API is deprecated.

+

Instead of .focusin( handler ) or .focusin( eventData, handler ), use .on( "focusin", handler ) or .on( "focusin", eventData, handler ), respectively.

+

Instead of .focusin(), use .trigger( "focusin" ).

+
+
+ + + + + +
diff --git a/entries/focusin.xml b/entries/focusin.xml index aaff429d..7b5288f6 100644 --- a/entries/focusin.xml +++ b/entries/focusin.xml @@ -1,16 +1,15 @@ - - .focusin() + + +Bind an event handler to the "focusin" event, or trigger that event on an element. + + focusin event Bind an event handler to the "focusin" event. - 1.4 - - A function to execute each time the event is triggered. - + 1.7 + + The string "focusin". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -19,15 +18,13 @@ - - 1.0 - -

This method is a shortcut for .on( "focusin", handler ) in the first two variations, and .trigger( "focusin" ) in the third.

+
+

This page describes the focusin event. For the deprecated .focusin() method, see .focusin().

+

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

This event will likely be used together with the focusout event.

- Watch for a focus to occur within the paragraphs on the page.
diff --git a/entries/hide.xml b/entries/hide.xml index b90aed05..53aab56d 100644 --- a/entries/hide.xml +++ b/entries/hide.xml @@ -49,7 +49,7 @@ $( ".target" ).hide();

 // With the element initially shown, we can hide it slowly:
-$( "#clickme" ).click(function() {
+$( "#clickme)" ).on( "click", function() {
   $( "#book" ).hide( "slow", function() {
     alert( "Animation complete." );
   });
@@ -68,7 +68,7 @@ $( "#clickme" ).click(function() {
     Hides all paragraphs then the link on click.
     
@@ -101,13 +101,13 @@ $( "button" ).click(function() {
   
     Animates all spans (words in this case) to hide fastly, completing each animation within 200 milliseconds. Once each animation is done, it starts the next one.
     
@@ -134,7 +134,7 @@ $( "#shower" ).click(function() {
 for ( var i = 0; i < 5; i++ ) {
   $( "
" ).appendTo( document.body ); } -$( "div" ).click(function() { +$( "div)" ).on( "click", function() { $( this ).hide( 2000, function() { $( this ).remove(); }); diff --git a/entries/hover.xml b/entries/hover.xml index 2ddab1fa..a924d368 100644 --- a/entries/hover.xml +++ b/entries/hover.xml @@ -1,7 +1,7 @@ Bind one or two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. - + .hover() Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. @@ -16,12 +16,15 @@ +
+

This API is deprecated. Use .on( "mouseenter", handlerIn ).on( "mouseleave", handlerOut ) instead.

+

The .hover() method binds handlers for both mouseenter and mouseleave events. You can use it to simply apply behavior to an element during the time the mouse is within the element.

Calling $( selector ).hover( handlerIn, handlerOut ) is shorthand for:


-$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
+$( selector ).on( "mouseenter", handlerIn ).on( "mouseleave", handlerOut );
       
-

See the discussions for .mouseenter() and .mouseleave() for more details.

+

See the discussions for mouseenter and mouseleave for more details.

To add a special style to list items that are being hovered over, try: @@ -80,8 +83,10 @@ $( "td" ).off( "mouseenter mouseleave" ); +
- + + Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements. 1.4 @@ -91,12 +96,15 @@ $( "td" ).off( "mouseenter mouseleave" ); +
+

This API is deprecated. Use .on( "mouseenter mouseleave", handlerInOut ) instead.

+

The .hover() method, when passed a single function, will execute that handler for both mouseenter and mouseleave events. This allows the user to use jQuery's various toggle methods within the handler or to respond differently within the handler depending on the event.type.

Calling $(selector).hover(handlerInOut) is shorthand for:


 $( selector ).on( "mouseenter mouseleave", handlerInOut );
       
-

See the discussions for .mouseenter() and .mouseleave() for more details.

+

See the discussions for mouseenter and mouseleave for more details.

Slide the next sibling LI up or down on hover, and toggle a class. @@ -143,5 +151,6 @@ $( "li" ) +
diff --git a/entries/html.xml b/entries/html.xml index b830c566..4be065f3 100644 --- a/entries/html.xml +++ b/entries/html.xml @@ -29,7 +29,7 @@ $( "div.demo-container" ).html(); Click a paragraph to convert it from html to text.
diff --git a/entries/jQuery.fx.off.xml b/entries/jQuery.fx.off.xml index 74bfd60a..3c93466d 100644 --- a/entries/jQuery.fx.off.xml +++ b/entries/jQuery.fx.off.xml @@ -20,10 +20,10 @@ var toggleFx = function() { $.fx.off = !$.fx.off; }; toggleFx(); -$( "button" ).click( toggleFx ); -$( "input" ).click(function() { +$( "button" ).on( "click", toggleFx ); +$( "input)" ).on( "click", function() { $( "div" ).toggle( "slow" ); -}); +} ); ]]> Queue a custom function. Selector Context

By default, selectors perform their searches within the DOM starting at the document root. However, an alternate context can be given for the search by using the optional second parameter to the $() function. For example, to do a search within an event handler, the search can be restricted like so:


-$( "div.foo" ).click(function() {
+$( "div.foo)" ).on( "click", function() {
   $( "span", this ).addClass( "bar" );
 });
       
@@ -62,7 +62,7 @@ $( "div.foo" ).click(function() {

Please note that although you can pass text nodes and comment nodes into a jQuery collection this way, most operations don't support them. The few that do will have an explicit note on their API documentation page.

A common use of single-DOM-element construction is to call jQuery methods on an element that has been passed to a callback function through the keyword this:


-$( "div.foo" ).click(function() {
+$( "div.foo)" ).on( "click", function() {
   $( this ).slideUp();
 });
       
diff --git a/entries/keydown-shorthand.xml b/entries/keydown-shorthand.xml new file mode 100644 index 00000000..98b125b3 --- /dev/null +++ b/entries/keydown-shorthand.xml @@ -0,0 +1,36 @@ + + + .keydown() + Bind an event handler to the "keydown" event, or trigger that event on an element. + + 1.0 + + A function to execute each time the event is triggered. + + + + + 1.4.3 + + An object containing data that will be passed to the event handler. + + + A function to execute each time the event is triggered. + + + + + 1.0 + + +
+

This API is deprecated.

+

Instead of .keydown( handler ) or .keydown( eventData, handler ), use .on( "keydown", handler ) or .on( "keydown", eventData, handler ), respectively.

+

Instead of .keydown(), use .trigger( "keydown" ).

+
+
+ + + + +
diff --git a/entries/keydown.xml b/entries/keydown.xml index f21ae4e0..576a1ad0 100644 --- a/entries/keydown.xml +++ b/entries/keydown.xml @@ -1,15 +1,15 @@ - - .keydown() + +Bind an event handler to the "keydown" event, or trigger that event on an element. + + + keydown event + Bind an event handler to the "keydown" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "keydown". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -18,12 +18,10 @@ - - 1.0 - - Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element. -

This method is a shortcut for .on( "keydown", handler ) in the first and second variations, and .trigger( "keydown" ) in the third.

+
+

This page describes the keydown event. For the deprecated .keydown() method, see .keydown().

+

The keydown event is sent to an element when the user presses a key on the keyboard. If the key is kept pressed, the event is sent every time the operating system repeats the key. It can be attached to any element, but the event is only sent to the element that has the focus. Focusable elements can vary between browsers, but form elements can always get focus so are reasonable candidates for this event type.

For example, consider the HTML:


@@ -36,42 +34,41 @@
     

The event handler can be bound to the input field:


-$( "#target" ).keydown(function() {
-  alert( "Handler for .keydown() called." );
-});
+$( "#target" ).on( "keydown", function() {
+  alert( "Handler for `keydown` called." );
+} );
     

Now when the insertion point is inside the field, pressing a key displays the alert:

- Handler for .keydown() called. + Handler for `keydown` called.

-

To trigger the event manually, apply .keydown() without an argument:

+

To trigger the event manually, use .trigger( "keydown" ):


-$( "#other" ).click(function() {
-  $( "#target" ).keydown();
-});
+$( "#other" ).on( "click", function() {
+  $( "#target" ).trigger( "keydown" );
+} );
     

After this code executes, clicks on Trigger the handler will also alert the message.

If key presses anywhere need to be caught (for example, to implement global shortcut keys on a page), it is useful to attach this behavior to the document object. Because of event bubbling, all key presses will make their way up the DOM to the document object unless explicitly stopped.

To determine which key was pressed, examine the event object that is passed to the handler function. While browsers use differing properties to store this information, jQuery normalizes the .which property so you can reliably use it to retrieve the key code. This code corresponds to a key on the keyboard, including codes for special keys such as arrows. For catching actual text entry, .keypress() may be a better choice.

- Show the event object for the keydown handler when a key is pressed in the input. diff --git a/entries/live.xml b/entries/live.xml index e88a67ce..26e7a563 100644 --- a/entries/live.xml +++ b/entries/live.xml @@ -104,7 +104,7 @@ $( "p" ).live( "myCustomEvent", function( event, myName, myValue ) { .fadeIn( 30 ) .fadeOut( 1000 ); }); -$( "button" ).click(function() { +$( "button)" ).on( "click", function() { $( "p" ).trigger( "myCustomEvent" ); }); ]]> diff --git a/entries/load-event.xml b/entries/load-event.xml index b9669cc6..f7dbc65a 100644 --- a/entries/load-event.xml +++ b/entries/load-event.xml @@ -1,16 +1,15 @@ - - .load() - Bind an event handler to the "load" JavaScript event. + +Bind an event handler to the "load" event, or trigger that event on an element. + + + load event + Bind an event handler to the "load" event. - 1.0 - - A function to execute when the event is triggered. - + 1.7 + + The string "load". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -21,9 +20,8 @@
-

Note: This API has been removed in jQuery 3.0; please use .on( "load", handler ) instead of .load( handler ) and .trigger( "load" ) instead of .load().

+

This page describes the load event. For the .load() method removed in jQuery 3.0, see .load().

-

This method is a shortcut for .on( "load", handler ).

The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

For example, consider a page with a simple image:


@@ -31,20 +29,17 @@
     

The event handler can be bound to the image:


-$( "#book" ).load(function() {
-  // Handler for .load() called.
-});
+$( "#book" ).on( "load", function() {
+  // Handler for `load` called.
+} );
     

As soon as the image has been loaded, the handler is called.

In general, it is not necessary to wait for all images to be fully loaded. If code can be executed earlier, it is usually best to place it in a handler sent to the .ready() method.

-
-

The Ajax module also has a method named .load(). Which one is fired depends on the set of arguments passed.

-

Caveats of the load event when used with images -

A common challenge developers attempt to solve using the .load() shortcut is to execute a function when an image (or collection of images) have completely loaded. There are several known caveats with this that should be noted. These are:

+

A common challenge developers attempt to solve using the load shortcut is to execute a function when an image (or collection of images) have completely loaded. There are several known caveats with this that should be noted. These are:

  • It doesn't work consistently nor reliably cross-browser
  • It doesn't fire correctly in WebKit if the image src is set to the same src as before
  • @@ -60,24 +55,40 @@ $( "#book" ).load(function() { Run a function when the page is fully loaded including graphics. Add the class bigImg to all images with height greater than 100 upon each image load. - - - + + + + + load event + Trigger the "load" event on an element. + + 1.0 + + The string "load". + + + +

    See the description for .on( "load", ... ).

    +
    + +
    + + diff --git a/entries/load-shorthand.xml b/entries/load-shorthand.xml new file mode 100644 index 00000000..1c5873cb --- /dev/null +++ b/entries/load-shorthand.xml @@ -0,0 +1,40 @@ + + + .load() + Bind an event handler to the "load" event, or trigger that event on an element. + + 1.0 + + A function to execute each time the event is triggered. + + + + + 1.4.3 + + An object containing data that will be passed to the event handler. + + + A function to execute each time the event is triggered. + + + + + 1.0 + + +
    +

    This API has been removed in jQuery 3.0.

    +

    Instead of .load( handler ) or .load( eventData, handler ), use .on( "load", handler ) or .on( "load", eventData, handler ), respectively.

    +

    Instead of .load(), use .trigger( "load" ).

    +
    +
    +

    The Ajax module also has a method named .load(). Which one is fired depends on the set of arguments passed.

    +
    +
    + + + + + +
    diff --git a/entries/map.xml b/entries/map.xml index c151e831..101fa001 100644 --- a/entries/map.xml +++ b/entries/map.xml @@ -135,9 +135,9 @@ $.fn.equalizeHeights = function() { return this.height( Math.max.apply( this, maxHeight ) ); }; -$( "input" ).click(function() { +$( "input" ).on( "click", function() { $( "div" ).equalizeHeights(); -}); +} ); ]]> 300 " ) .parent() - .css({ + .css( { background: "yellow", border: "3px red solid" - }); + } ); $( "div" ) .text( "For this type jQuery found " + input.length + "." ) .css( "color", "red" ); // Prevent form submission -$( "form" ).submit(function( event ) { +$( "form" ).on( "submit", function( event ) { event.preventDefault(); -}); +} ); ]]> diff --git a/entries/removeAttr.xml b/entries/removeAttr.xml index 92a92b22..46ce85b2 100644 --- a/entries/removeAttr.xml +++ b/entries/removeAttr.xml @@ -22,7 +22,7 @@ console.log( "onclick property: ", $element[ 0 ].onclick ); @@ -108,7 +108,7 @@ $( "p" ).replaceWith( "Paragraph. " ); On click, replace each paragraph with a div that is already in the DOM and selected with the $() function. Notice it doesn't clone the object but rather moves it to replace the paragraph. diff --git a/entries/reset-selector.xml b/entries/reset-selector.xml index 301b0e5e..db558608 100644 --- a/entries/reset-selector.xml +++ b/entries/reset-selector.xml @@ -13,18 +13,18 @@ Finds all reset inputs. - + + + + + resize event + Trigger the "resize" event on an element. + + 1.0 + + The string "resize". + + + +

    See the description for .on( "resize", ... ).

    +
    + +
    + + diff --git a/entries/scroll-shorthand.xml b/entries/scroll-shorthand.xml new file mode 100644 index 00000000..67b7997e --- /dev/null +++ b/entries/scroll-shorthand.xml @@ -0,0 +1,36 @@ + + + .scroll() + Bind an event handler to the "scroll" event, or trigger that event on an element. + + 1.0 + + A function to execute each time the event is triggered. + + + + + 1.4.3 + + An object containing data that will be passed to the event handler. + + + A function to execute each time the event is triggered. + + + + + 1.0 + + +
    +

    This API is deprecated.

    +

    Instead of .scroll( handler ) or .scroll( eventData, handler ), use .on( "scroll", handler ) or .on( "scroll", eventData, handler ), respectively.

    +

    Instead of .scroll(), use .trigger( "scroll" ).

    +
    +
    + + + + +
    diff --git a/entries/scroll.xml b/entries/scroll.xml index 8529cb0c..5f46ddfe 100644 --- a/entries/scroll.xml +++ b/entries/scroll.xml @@ -1,16 +1,15 @@ - - .scroll() - Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element. + + +Bind an event handler to the "scroll" event, or trigger that event on an element. + + scroll event + Bind an event handler to the "scroll" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "scroll". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -19,11 +18,10 @@ - - 1.0 - -

    This method is a shortcut for .on( "scroll", handler ) in the first and second variations, and .trigger( "scroll" ) in the third.

    +
    +

    This page describes the scroll event. For the deprecated .scroll() method, see .scroll().

    +

    The scroll event is sent to an element when the user scrolls to a different place in the element. It applies to window objects, but also to scrollable frames and elements with the overflow CSS property set to scroll (or auto when the element's explicit height or width is less than the height or width of its contents).

    For example, consider the HTML:

    
    @@ -41,7 +39,7 @@
       Trigger the handler
     </div>
     <div id="log"></div>
    -
    +

The style definition is present to make the target element small enough to be scrollable:

@@ -49,33 +47,32 @@

The scroll event handler can be bound to this element:


-$( "#target" ).scroll(function() {
-  $( "#log" ).append( "<div>Handler for .scroll() called.</div>" );
-});
+$( "#target" ).on( "scroll", function() {
+  $( "#log" ).append( "<div>Handler for `scroll` called.</div>" );
+} );
     

Now when the user scrolls the text up or down, one or more messages are appended to <div id="log"></div>:

- Handler for .scroll() called. + Handler for `scroll` called.

-

To trigger the event manually, apply .scroll() without an argument:

+

To trigger the event manually, use .trigger( "scroll" ):


-$( "#other" ).click(function() {
-  $( "#target" ).scroll();
-});
+$( "#other" ).on( "click", function() {
+  $( "#target" ).trigger( "scroll" );
+} );
     

After this code executes, clicks on Trigger the handler will also append the message.

A scroll event is sent whenever the element's scroll position changes, regardless of the cause. A mouse click or drag on the scroll bar, dragging inside the element, pressing the arrow keys, or using the mouse's scroll wheel could cause this event.

- To do something when your page is scrolled: - + + + + + select event + Trigger the "select" event on an element. + + 1.0 + + The string "select". + + + +

See the description for .on( "select", ... ).

+
+ +
+ + diff --git a/entries/selected-selector.xml b/entries/selected-selector.xml index c96bf422..5eb6cef8 100644 --- a/entries/selected-selector.xml +++ b/entries/selected-selector.xml @@ -14,13 +14,13 @@ Attaches a change event to the select that gets the text for each selected option and writes them in the div. It then triggers the event for the initial text draw. @@ -84,13 +84,13 @@ $( "button" ).click(function() { Show the first div, followed by each next adjacent sibling div in order, with a 200ms animation. Each animation starts when the previous sibling div's animation ends. @@ -120,19 +120,19 @@ function doIt() { $( "span,div" ).show( "slow" ); } // Can pass in function name -$( "button" ).click( doIt ); +$( "button" ).on( "click", doIt ); -$( "form" ).submit(function( event ) { +$( "form" ).on( "submit", function( event ) { if ( $( "input" ).val() === "yes" ) { $( "p" ).show( 4000, function() { $( this ).text( "Ok, DONE! (now showing)" ); - }); + } ); } $( "span,div" ).hide( "fast" ); // Prevent form submission event.preventDefault(); -}); +} ); ]]> diff --git a/entries/slice.xml b/entries/slice.xml index 81d76c98..8f94ce16 100644 --- a/entries/slice.xml +++ b/entries/slice.xml @@ -62,7 +62,7 @@ function colorEm() { ").css( 'background', 'yellow' );" ); } -$( "button" ).click( colorEm ); +$( "button" ).on( "click", colorEm ); ]]> @@ -84,7 +84,7 @@ $( "button" ).click(function() { Animates divs between dividers with a toggle that makes some appear and some disappear. diff --git a/entries/submit-selector.xml b/entries/submit-selector.xml index a4c9aa01..f6c48b8f 100644 --- a/entries/submit-selector.xml +++ b/entries/submit-selector.xml @@ -15,25 +15,25 @@ " ); -}) +} ); ]]> To trigger the submit event on the first form on the page, try: - + + + + submit event + Trigger the "submit" event on an element. + + 1.0 + + The string "submit". + + + +

See the description for .on( "submit", ... ).

+
+ + +
+ + diff --git a/entries/text-selector.xml b/entries/text-selector.xml index 9af4dc44..4886c3a5 100644 --- a/entries/text-selector.xml +++ b/entries/text-selector.xml @@ -19,19 +19,19 @@ $( "<input>" ).is( ":text" ); // true Finds all text inputs. @@ -126,7 +126,7 @@ $( "button" ).click(function() { Shows all paragraphs, then hides them all, back and forth. diff --git a/entries/toggleClass.xml b/entries/toggleClass.xml index 3ce8196c..fcb8da42 100644 --- a/entries/toggleClass.xml +++ b/entries/toggleClass.xml @@ -99,7 +99,7 @@ $( "div.foo" ).toggleClass(function() { Toggle the class 'highlight' when a paragraph is clicked. @@ -128,15 +128,15 @@ $( "p" ).click(function() { Add the "highlight" class to the clicked paragraph on every third click of that paragraph, remove it every first and second click. Clicks to button #2 also trigger a click for button #1. diff --git a/entries/triggerHandler.xml b/entries/triggerHandler.xml index d72516a8..fb2da985 100644 --- a/entries/triggerHandler.xml +++ b/entries/triggerHandler.xml @@ -37,15 +37,15 @@ If you called .triggerHandler() on a focus event - the browser's default focus action would not be triggered, only the event handlers bound to the focus event. - - - + + + + + unload event + Trigger the "unload" event on an element. + + 1.0 + + The string "unload". + + + +

See the description for .on( "unload", ... ).

+
+ +
+ + diff --git a/entries/unwrap.xml b/entries/unwrap.xml index ff6d6100..1ba959aa 100644 --- a/entries/unwrap.xml +++ b/entries/unwrap.xml @@ -18,7 +18,7 @@ Wrap/unwrap a div around each of the paragraphs. Set the value of an input box.