diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..8b808995d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.js, *.xsl]
+indent_style = tab
diff --git a/.github/configs/hydra-config.json b/.github/configs/hydra-config.json
new file mode 100644
index 000000000..2173722b4
--- /dev/null
+++ b/.github/configs/hydra-config.json
@@ -0,0 +1,10 @@
+{
+ "//": [
+ "2023-05: twitter.com serves broken redirect-loop",
+ "2025-04: The oembed endpoint responds HTTP 429 Too Many Requests too often; perhaps because almost every page links to one"
+ ],
+ "exclude_scheme_prefixes": [
+ "https://twitter.com/",
+ "https://api.jquery.com/wp-json/oembed/1.0/embed"
+ ]
+}
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..aa2f74565
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,13 @@
+version: 2
+updates:
+ - package-ecosystem: github-actions
+ directory: "/"
+ schedule:
+ interval: monthly
+
+ # Group all dependabot version update PRs into one
+ groups:
+ github-actions:
+ applies-to: version-updates
+ patterns:
+ - "*"
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
new file mode 100644
index 000000000..30412870c
--- /dev/null
+++ b/.github/workflows/node.js.yml
@@ -0,0 +1,32 @@
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
+
+name: Node.js CI
+
+on:
+ pull_request:
+ push:
+ branches-ignore: "dependabot/**"
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ node-version: [18.x, 20.x]
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Update apt-get cache
+ run: sudo apt-get update
+ - name: Install xmllint
+ run: sudo apt-get install -y libxml2-utils
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
+ with:
+ node-version: ${{ matrix.node-version }}
+ cache: 'npm'
+ - run: npm ci
+ - run: npm test
diff --git a/.github/workflows/spider-check.yaml b/.github/workflows/spider-check.yaml
new file mode 100644
index 000000000..95ea1ea24
--- /dev/null
+++ b/.github/workflows/spider-check.yaml
@@ -0,0 +1,32 @@
+name: spider-check
+on:
+ # Once a week on Friday at 00:00
+ schedule:
+ - cron: '0 0 * * 5'
+ # Or manually
+ workflow_dispatch:
+ # Or when developing this workflow
+ push:
+ paths:
+ - .github/workflows/spider-check.yaml
+ - .github/configs/hydra-config.json
+ pull_request:
+ paths:
+ - .github/workflows/spider-check.yaml
+ - .github/configs/hydra-config.json
+
+jobs:
+ spider-check:
+ if: ${{ github.repository_owner == 'jquery' }} # skip on forks
+ runs-on: ubuntu-latest
+ env:
+ # Site address to crawl
+ MY_SITE: https://api.jquery.com
+ steps:
+ - name: Checkout
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ - name: Run hydra-link-checker
+ run: |
+ curl -O https://raw.githubusercontent.com/jquery/hydra-link-checker/v2.0.0/hydra.py
+ python3 hydra.py "$MY_SITE" --config .github/configs/hydra-config.json
diff --git a/.github/workflows/typesense.yaml b/.github/workflows/typesense.yaml
new file mode 100644
index 000000000..de973410d
--- /dev/null
+++ b/.github/workflows/typesense.yaml
@@ -0,0 +1,30 @@
+name: typesense
+on:
+ # Once a day at 11:30 UTC All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the jQuery 1.3 Release Notes. All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the jQuery 1.4 Release Notes All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the Release Notes/Changelog at https://blog.jquery.com/2011/11/03/jquery-1-7-released/ All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the Release Notes/Changelog at https://blog.jquery.com/2012/08/09/jquery-1-8-released/ All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the Release Notes/Changelog at https://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/ All the aspects of the API that were deprecated in the corresponding version of jQuery. For more information, see the Release Notes/Changelog at https://blog.jquery.com/2013/05/24/jquery-1-10-0-and-2-0-1-released/
For more information, see the Release Notes/Changelog at https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/
+ ]]>For more information, see the Release Notes/Changelog at https://blog.jquery.com/2017/03/16/jquery-3-2-0-is-out/
+ ]]>For more information, see the Release Notes/Changelog at https://blog.jquery.com/2018/01/19/jquery-3-3-0-a-fragrant-bouquet-of-deprecations-and-is-that-a-new-feature/
+ ]]>For more information, see the Release Notes/Changelog at https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/
+ ]]>For more information, see the Release Notes/Changelog at https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/
]]>For more information, see the Release Notes/Changelog at https://blog.jquery.com/2023/05/11/jquery-3-7-0-released-staying-in-order/
]]>.attr()
, .html()
, and .val()
—also act as "getters," retrieving information from DOM elements for later use.
- ]]>.attr()
, .html()
, and .val()
—also act as "getters," retrieving information from DOM elements for later use.
+ ]]>
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.0 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ Release Notes: 1.0.1, 1.0.2, 1.0.3, 1.0.4. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.1 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.1.2 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.1.3 Release Notes +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.1.4 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.2 Release Notes +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ Release Notes: 1.2.1, 1.2.2, 1.2.3. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.2.6 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ Release Notes: 1.3, 1.3.1, 1.3.2 +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.4 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.4.1 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.4.2 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.4.3 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+ jQuery 1.4.4 Release Notes. +All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
-jQuery 1.5 also includes a large rewrite of the Ajax module, which has a number of extensibility improvements. You can find out more about those improvements in the Extending Ajax documentation.
-Additionally jQuery 1.5 includes a new Deferred callback management system you can learn more about in in the Deferred Object documentation.
+jQuery 1.5 also includes a large rewrite of the Ajax module, which has a number of extensibility improvements. You can find out more about those improvements in the Extending Ajax documentation.
+Additionally, jQuery 1.5 includes a new Deferred callback management system you can learn more about in the Deferred Object documentation.
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+API changes in jQuery 1.5.1 dealt primarily with jQuery.ajax settings and jQuery.support properties.
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+.on()
and .off()
- Better Support for HTML5 in IE6/7/8
- jQuery.Callbacks()
- Toggling Animations Work Intuitively
-
- For more information, see the Release Notes/Changelog at https://blog.jquery.com/2011/11/03/jquery-1-7-released/
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+jQuery 1.7.0 included:
+.on()
and .off()
jQuery.Callbacks()
For more information, see the Release Notes/Changelog
deferred.isResolved()
, deferred.isRejected()
, $.curCSS()
, $.attrFn()
, and $(element).closest(Array)
returning Array.
-
- For more information, see the Release Notes/Changelog at https://blog.jquery.com/2012/08/09/jquery-1-8-released/
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+API changes in jQuery 1.8.0 dealt primarily with animations and the removal of some methods such as deferred.isResolved()
, deferred.isRejected()
, $.curCSS()
, $.attrFn()
, and $(element).closest(Array)
returning Array.
For more information, see the Release Notes/Changelog
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Changes in jQuery 1.9 dealt primarily with removal or modification of several APIs that behaved inconsistently or inefficiently in the past.
+A jQuery Migrate Plugin was offered to help developers with a transitional upgrade path.
For more information, see the jQuery Core 1.9 Upgrade guide and the Release Notes/Changelog
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Changes in jQuery 1.10 and 2.0 include a new `wrap` module, relaxing HTML parsing, and aligning the 1.x & 2.x lines.
+For more information, see the 2.0 Release Notes/Changelog and 1.10.0/2.0.1 Release Notes/Changelog.
+For more information, see the Release Notes/Changelog
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Changes in jQuery 1.11 and 2.1 include lower startup overhead & fewer forced layouts; jQuery is now authored via AMD and published to npm & bower under the name jquery
.
For more information, see the Release Notes/Changelog.
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Changes in jQuery 1.12 and 2.2 include performance improvements of the selector engine, manipulation of class names for SVG elements, support for the Symbol type and iterators added in ES2015, and a new hook has been added for filtering HTML.
+For more information, see the Release Notes/Changelog.
For more information, see the jQuery Core 3.0 Upgrade guide and the Release Notes/Changelog
+All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Changes in jQuery 3.0 dealt primarily with deferreds, data, show/hide and removal of some deprecated APIs. A jQuery Migrate Plugin was offered to help developers with a transitional upgrade path.
+For more information, see the jQuery Core 3.0 Upgrade guide and the Release Notes/Changelog.
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+Version 3.1 added the jQuery.readyException API.
+For more information, see the Release Notes/Changelog.
+Version 3.2 added support for custom CSS properties, made .contents()
work on the <template>
element & made .width()
& .height()
ignore CSS transforms. A few APIs were deprecated. The deprecated module was added back to the slim build.
For more information, see the Release Notes/Changelog.
+.addClass()
, .removeClass()
& .toggleClass()
now work on arrays of classes; a few APIs were deprecated.
For more information, see the Release Notes/Changelog.
+nonce
& nomodule
attributes are now preserved during script manipulation, layout thrashing was eliminated in some cases in .width()
& .height()
APIs. Radio elements state is now updated before event handlers run. Passing data now works when triggering all events, including focus
. A minor security fix is also included.
For more information, see the Release Notes/Changelog.
+Security fixes, including a breaking change to jQuery.htmlPrefilter
; new .even()
& .odd()
methods; jQuery.globalEval
now accepts context; unsuccessful HTTP script responses are no longer evaluated; performance improvements. jQuery.trim
is now deprecated. A jQuery Migrate Plugin was offered to help developers with a transitional upgrade path.
For more information, see the jQuery Core 3.5 Upgrade guide and the Release Notes/Changelog.
+Returning JSON even for JSONP erroneous responses is working again, a few focus fixes.
+For more information, see the Release Notes/Changelog.
+New .uniqueSort()
method performance improvements in manipulation, fixes for .outerWidth( true )
& .outerHeight( true )
with negative margins, focus fixes.
As of this release, jQuery no longer relies on Sizzle.
+Native events for focus
& blur
changed in IE to - respectively - focusin
and focusout
.
For more information, see the Release Notes/Changelog.
+Aspects of the API that were changed in the corresponding version of jQuery.
+Dropped support for IE <11 & Edge Legacy, removed deprecated APIs, added FormData support, improved support for CSP & Trusted Types. Automatic JSONP promotion removed. Special handling of boolean attributes removed.
+Callbacks & Deferred modules are now excluded from the Slim build.
+jQuery is now authored in ESM.
+For more information, see the Release Notes/Changelog of jQuery 4.0.0-beta.2.
this
refers to the current element in the set.It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.
@@ -64,7 +80,30 @@ $( "p" ).last().addClass( "selected" );
+ and
+Goodbye
+]]> +
this
refers to the current element in the set.This API is deprecated. Use .on( "ajaxComplete", handler )
instead.
"ajaxComplete"
.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
.
Request Complete." );
-});
+} );
]]>
This API is deprecated. Use .on( "ajaxError", handler )
instead.
"ajaxError"
.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." );
}
-});
+} );
+
Error requesting page " + settings.url + "" );
-});
+} );
]]>
This API is deprecated. Use .on( "ajaxSend", handler )
instead.
"ajaxSend"
.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, XMLHttpRequest
object), 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." );
}
-});
+} );
Starting request at " + settings.url + "" );
-});
+} );
]]>
This API is deprecated. Use .on( "ajaxStart", handler )
instead.
"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 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.
This API is deprecated. Use .on( "ajaxStop", handler )
instead.
"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 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.
This API is deprecated. Use .on( "ajaxSuccess", handler )
instead.
"ajaxSuccess"
.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.
Successful Request!" );
-});
+} );
]]>
Note: This function has been deprecated and is now an alias for .addBack()
, which should be used with jQuery 1.8 and later.
As described in the discussion for .end()
, jQuery objects maintain an internal stack that keeps track of changes to the matched set of elements. When one of the DOM traversal methods is called, the new set of elements is pushed onto the stack. If the previous set of elements is desired as well, .andSelf()
can help.
Consider a page with a simple list on it:
-
-<ul>
- <li>list item 1</li>
- <li>list item 2</li>
- <li class="third-item">list item 3</li>
- <li>list item 4</li>
- <li>list item 5</li>
-</ul>
-
- The result of the following code is a red background behind items 3, 4 and 5:
-
-$( "li.third-item" ).nextAll().andSelf()
- .css( "background-color", "red" );
-
- First, the initial selector locates item 3, initializing the stack with the set containing just this item. The call to .nextAll()
then pushes the set of items 4 and 5 onto the stack. Finally, the .andSelf()
invocation merges these two sets together, creating a jQuery object that points to all three items in document order: [ <li.third-item>, <li>, <li> ]
.
Note: This API has been removed in jQuery 3.0; use .addBack()
instead, which should work identically.
.andSelf()
method causes the previous set of DOM elements in the traversal stack to be added to the current set. In the first example, the top stack contains the set resulting from .find("p")
. In the second example, .andSelf()
adds the previous set of elements on the stack — in this case $( "div.after-andself" )
— to the current set, selecting both the div and its enclosed paragraphs. p" ).addClass( "border" );
-
-// First Example
-$( "div.before-andself" ).find( "p" ).addClass( "background" );
-
-// Second Example
-$( "div.after-andself" ).find( "p" ).andSelf().addClass( "background" );
-]]>
- Before andSelf()
First Paragraph
-Second Paragraph
-After andSelf()
First Paragraph
-Second Paragraph
-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() {
Animates a div's left property with a relative value. Click several times on the buttons to see the relative animations queued up.
@@ -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.
Animates the first div's left property and synchronizes the remaining divs, using the step function to set their left properties at each stage of the animation.
Change the color of any div that is animated.
If there is more than one target element, however, cloned copies of the inserted element will be created for each target except the last, and that new set (the original element plus clones) is returned.
- Before jQuery 1.9, the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the .end()
method reliably when being used with an unknown number of elements.
+ Before jQuery 1.9, the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the .end()
method reliably when being used with an unknown number of elements.
The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr()
method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop()
method provides a way to explicitly retrieve property values, while .attr()
retrieves attributes.
For example, selectedIndex
, tagName
, nodeName
, nodeType
, ownerDocument
, defaultChecked
, and defaultSelected
should be retrieved and set with the .prop()
method. Prior to jQuery 1.6, these properties were retrievable with the .attr()
method, but this was not within the scope of attr
. These do not have corresponding attributes and are only properties.
Concerning boolean attributes, consider a DOM element defined by the HTML markup <input type="checkbox" checked="checked" />
, and assume it is in a JavaScript variable named elem
:
Concerning boolean attributes, consider a DOM element defined by the HTML markup <input type="checkbox" checked="" />
, and assume it is in a JavaScript variable named elem
:
@@ -44,21 +44,21 @@ |
elem.getAttribute( "checked" )
|
- "checked" (String) Initial state of the checkbox; does not change |
+ "" (String) Initial state of the checkbox; does not change |
---|---|---|---|
$( elem ).attr( "checked" )
- (1.6)
+ (4.0+)
|
- "checked" (String) Initial state of the checkbox; does not change |
+ "" (String) Initial state of the checkbox; does not change |
|
$( elem ).attr( "checked" )
- (1.6.1+)
+ (1.6-3.x)
|
- "checked" (String) Will change with checkbox state |
+ "checked" (String) Initial state of the checkbox; does not change |
|
@@ -89,13 +89,13 @@
" + $input.attr( "checked" ) + "
null , the specified attribute will be removed (as in .removeAttr() ).null , the specified attribute will be removed (as in .removeAttr() ). Non-ARIA attributes can also be removed by passing false .When setting multiple attributes, the quotes around attribute names are optional. +Removing an attribute+To remove an attribute, either call
+
Note: Because ARIA attributes frequently associate behavior with "false" values that differs from attribute absence, passing WARNING: When setting the 'class' attribute, you must always use quotes! Note: Attempting to change the As of jQuery 3.0, Any string is legal for If the There are shorthand methods for some standard browser events such as Some events have dedicated pages, describing specifics of their usage. For a complete list of those events, see the events category. When an event reaches an element, all handlers bound to that event type for the element are fired. If there are multiple handlers registered, they will always execute in the order in which they were bound. After all handlers have executed, the event continues along the normal event propagation path. A basic usage of
This method is a shortcut for
+
This page describes the The For example, consider the HTML:
+ The event handler can be bound to the first input field: +
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 To trigger the event programmatically, call
After this code executes, clicks on Trigger the handler will also alert the message. -The The The native
"blur" .See the description for
+
+ This API is deprecated. +Instead of Instead of "change" .This method is a shortcut for
+
This page describes the The For example, consider the HTML:
The event handler can be bound to the text input and the select box:
- Now when the second option is selected from the dropdown, the alert is displayed. It is also displayed if you change the text in the field and then click away. If the field loses focus without the contents having changed, though, the event is not triggered. To trigger the event manually, apply Now when the second option is selected from the dropdown, the alert is displayed. It is also displayed if you change the text in the field and then click away. If the field loses focus without the contents having changed, though, the event is not triggered. To trigger the event manually, use
After this code executes, clicks on Trigger the handler will also alert the message. The message will display twice, because the handler has been bound to the As of jQuery 1.4, the
"change" .See the description for
+ |