diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8b808995 --- /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 00000000..2173722b --- /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 00000000..aa2f7456 --- /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 00000000..26f673d8 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,30 @@ +# 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: Install xmllint + run: sudo apt-get install -y libxml2-utils + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.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 00000000..95ea1ea2 --- /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 00000000..de973410 --- /dev/null +++ b/.github/workflows/typesense.yaml @@ -0,0 +1,30 @@ +name: typesense +on: + # Once a day at 11:30 UTC + schedule: + - cron: '30 11 * * *' + # Or after a deployment + push: + branches: + - main + # Or manually + workflow_dispatch: + +jobs: + typesense: + name: Update Typesense + if: ${{ github.repository_owner == 'jquery' }} # skip on forks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Docsearch Scraper + shell: bash + run: | + docker run \ + -e TYPESENSE_API_KEY=${{ secrets.TYPESENSE_ADMIN_KEY }} \ + -e TYPESENSE_HOST="${{ secrets.TYPESENSE_HOST }}" \ + -e TYPESENSE_PORT="443" \ + -e TYPESENSE_PROTOCOL="https" \ + -e CONFIG="$(cat docsearch.config.json | jq -r tostring)" \ + typesense/docsearch-scraper:0.9.1 diff --git a/.mailmap b/.mailmap index 175ab74f..5f931fbc 100644 --- a/.mailmap +++ b/.mailmap @@ -1 +1,6 @@ Matic Potočnik +Michał Gołębiowski-Owczarek +Timmy Willison +Timmy Willison <4timmywil@gmail.com> +Timmy Willison +Timo Tijhof diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..3c032078 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba9f6b8f..9a004cd3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ -Welcome! Thanks for your interest in contributing to api.jquery.com. You're **almost** in the right place. More information on how to contribute to this and all other jQuery Foundation projects is over at [contribute.jquery.org](http://contribute.jquery.org). You'll definitely want to take a look at the articles on contributing [documentation](http://contribute.jquery.org/documentation). +Welcome! Thanks for your interest in contributing to api.jquery.com. You're **almost** in the right place. More information on how to contribute to this and all other jQuery Foundation projects is over at [contribute.jquery.org](https://contribute.jquery.org). You'll definitely want to take a look at the articles on contributing [documentation](https://contribute.jquery.org/documentation). -You may also want to take a look at our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla). +You may also want to take a look at our [commit & pull request guide](https://contribute.jquery.org/commits-and-pull-requests/) and [style guides](https://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](https://contribute.jquery.org/cla). -You can find us on [IRC](http://irc.jquery.org), specifically in #jquery-dev and #jquery-content should you have any questions. If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](http://contribute.jquery.org/open-source/). +You can find us on [IRC](https://irc.jquery.org), specifically in #jquery-dev and #jquery-content should you have any questions. If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](https://contribute.jquery.org/open-source/). diff --git a/Gruntfile.js b/Gruntfile.js index cc71e7be..10aa18ab 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,7 +22,12 @@ grunt.initConfig({ all: "resources/**" }, wordpress: (function() { - var config = require( "./config" ); + + // There's no config for CI, but we don't need one for basic testing + var config = {}; + try { + config = require( "./config" ); + } catch ( error ) {} config.dir = "dist/wordpress"; return config; })() @@ -38,4 +43,6 @@ grunt.registerTask( "build", [ "build-xml-full" ]); +grunt.registerTask( "deploy", [ "wordpress-deploy", "deploy-redirects" ] ); + }; diff --git a/LICENSE.txt b/LICENSE.txt index 19a9bad2..203b68a7 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright Packt Publishing (http://packtpub.com/), +Copyright Packt Publishing (https://www.packtpub.com/), jQuery Foundation (https://jquery.org/), and other contributors. This software consists of voluntary contributions made by many @@ -35,7 +35,7 @@ Copyright and related rights for sample code are waived via CC0. Sample code is defined as all source code displayed within the prose of the documentation and all examples and demos. -CC0: http://creativecommons.org/publicdomain/zero/1.0/ +CC0: https://creativecommons.org/publicdomain/zero/1.0/ ==== diff --git a/README.md b/README.md index f720120c..f7920803 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,16 @@ ## Building and Deploying -To build and deploy your changes for previewing in a [`jquery-wp-content`](https://github.com/jquery/jquery-wp-content) instance, follow the [workflow instructions](http://contribute.jquery.org/web-sites/#workflow) from our documentation on [contributing to jQuery Foundation web sites](http://contribute.jquery.org/web-sites/). +To build and deploy your changes for previewing in a [`jquery-wp-content`](https://github.com/jquery/jquery-wp-content) instance, follow the [workflow instructions](https://contribute.jquery.org/web-sites/#workflow) from our documentation on [contributing to jQuery Foundation web sites](https://contribute.jquery.org/web-sites/). ### Requirements * [libxml2](http://xmlsoft.org/) * [libxslt](http://xmlsoft.org/libxslt/) -The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from zlatkovic.com. +The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from zlatkovic.com. + +**Note**: If you're using Windows and you receive the error "Error" when executing the task `build-xml-entries:all`, try to add the DLL `libwinpthread-1.dll` in the root of the project. ## Style Guidelines @@ -32,7 +34,7 @@ The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Wi #### Pronoun Usage * Use second-person pronoun ("you") when necessary, but try to avoid it. -* Favor the definite article ("the") over second-person possesive ("your"). +* Favor the definite article ("the") over second-person possessive ("your"). * **Yes**: Insert the paragraph after the unordered list. * **No**: Insert your paragraph after the unordered list. * When editing current entries, change first-person plural pronouns ("we," "our," "us") to second-person. @@ -47,7 +49,7 @@ The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Wi ### Code Style -Code in the API documentation should follow the [jQuery Core Style Guide](http://contribute.jquery.org/style-guide/) with the following addition: +Code in the API documentation should follow the [jQuery Core Style Guide](https://contribute.jquery.org/style-guide/) with the following addition: * **Document ready syntax**: Use `$( document ).ready(function() {` instead of `$(function() {` as it's harder for new users to distinguish the difference between the latter and an IIFE. @@ -83,5 +85,5 @@ Code in the API documentation should follow the [jQuery Core Style Guide](http:/ * Strong in English writing * Tone * Middle ground between formal and familiar. Err on the side of formality. - * Authoritive + * Authoritative * Tactful diff --git a/categories.xml b/categories.xml index d4941b0e..8dc523ec 100644 --- a/categories.xml +++ b/categories.xml @@ -37,38 +37,80 @@ - For more information, see the jQuery 1.3 Release Notes.

+ This version is no longer supported. Read more about our Version Support. +

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.

]]>
- For more information, see the jQuery 1.4 Release Notes

+ This version is no longer supported. Read more about our Version Support. +

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

]]>
- For more information, see the Release Notes/Changelog at http://blog.jquery.com/2011/11/03/jquery-1-7-released/

+ This version is no longer supported. Read more about our Version Support. +

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/

]]>
- For more information, see the Release Notes/Changelog at http://blog.jquery.com/2012/08/09/jquery-1-8-released/

+ This version is no longer supported. Read more about our Version Support. +

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/

]]>
- For more information, see the Release Notes/Changelog at http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/

+ This version is no longer supported. Read more about our Version Support. +

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/

+ ]]>
+
+ + These versions are no longer supported. Read more about our Version Support. +

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/

+ ]]>
+
+ + 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/2016/06/09/jquery-3-0-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/2017/03/16/jquery-3-2-0-is-out/

+ ]]>
+
+ + 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/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 http://blog.jquery.com/2013/05/24/jquery-1-10-0-and-2-0-1-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/2019/04/10/jquery-3-4-0-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/2020/04/10/jquery-3-5-0-released/

]]>
- + @@ -98,7 +140,7 @@ jQuery's event system normalizes the event object according to W3C standards. The event object is guaranteed to be passed to the event handler. Most properties from the original event are copied over and normalized to the new event object.

+

jQuery's event system normalizes the event object according to W3C standards. The event object is guaranteed to be passed to the event handler. Most properties from the original event are copied over and normalized to the new event object.

jQuery.Event Constructor

The jQuery.Event constructor is exposed and can be used when calling trigger. The new operator is optional.

@@ -120,7 +162,7 @@ var e = jQuery.Event( "keydown", { keyCode: 64 } ); // trigger an artificial keydown event with keyCode 64 jQuery( "body" ).trigger( e ); -

Event Properties

+

Common Event Properties

jQuery normalizes the following properties for cross-browser consistency:

  • @@ -143,14 +185,13 @@ jQuery( "body" ).trigger( e );

The following properties are also copied to the event object, though some of their values may be undefined depending on the event:

-

altKey, bubbles, button, cancelable, charCode, clientX, clientY, ctrlKey, currentTarget, data, detail, eventPhase, metaKey, offsetX, offsetY, originalTarget, pageX, pageY, relatedTarget, screenX, screenY, shiftKey, target, view, which

-

OtherProperties

-

Certain events may have properties specific to them. Those can be accessed as properties of the event.originalEvent object.

-

Example:

+

altKey, bubbles, button, buttons, cancelable, char, charCode, clientX, clientY, ctrlKey, currentTarget, data, detail, eventPhase, key, keyCode, metaKey, offsetX, offsetY, originalTarget, pageX, pageY, relatedTarget, screenX, screenY, shiftKey, target, toElement, view, which

+

Other Properties

+

To access event properties not listed above, use the event.originalEvent object:


-// add the dataTransfer property for use with the native `drop` event
-// to capture information about files dropped into the browser window
-jQuery.event.props.push( "dataTransfer" );
+// Access the `dataTransfer` property from the `drop` event which
+// holds the files dropped into the browser window.
+var files = event.originalEvent.dataTransfer.files;
 
]]>
@@ -166,15 +207,15 @@ jQuery.event.props.push( "dataTransfer" );
- + Attributes category), while others set an element's style properties (also listed in the CSS category). Still others modify entire elements (or groups of elements) themselves—inserting, copying, removing, and so on. All of these methods are referred to as "setters," as they change the values of properties. - A few of these methods—such as .attr(), .html(), and .val()—also act as "getters," retrieving information from DOM elements for later use. - ]]> + A few of these methods—such as .attr(), .html(), and .val()—also act as "getters," retrieving information from DOM elements for later use. + ]]> @@ -239,13 +280,13 @@ jQuery.event.props.push( "dataTransfer" ); Borrowing from CSS 1–3, and then adding its own, jQuery offers a powerful set of tools for matching a set of elements in a document.

-

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.

+

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.

]]>
The CSS specification allows elements to be identified by their attributes. While not supported by some older browsers for the purpose of styling documents, jQuery allows you to employ them regardless of the browser being used.

When using any of the following attribute selectors, you should account for attributes that have multiple, space-separated values. Since these selectors see attribute values as a single string, this selector, for example, $("a[rel='nofollow']"), will select <a href="example.html" rel="nofollow">Some text</a> but not <a href="example.html" rel="nofollow foe">Some text</a>.

-

Attribute values in selector expressions must follow the rules for W3C CSS selectors; in general, that means anything other than a valid identifier should be surrounded by quotation marks.

+

Attribute values in selector expressions must follow the rules for W3C CSS selectors; in general, that means anything other than a valid identifier should be surrounded by quotation marks.

  • double quotes inside single quotes: $('a[rel="nofollow self"]')
  • single quotes inside double quotes: $("a[rel='nofollow self']")
  • @@ -259,7 +300,7 @@ jQuery.event.props.push( "dataTransfer" ); - http://www.w3.org/Style/CSS/#specs. ]]> + https://www.w3.org/Style/CSS/#specs. ]]> @@ -277,7 +318,7 @@ jQuery.event.props.push( "dataTransfer" ); - querySelectorAll() method. To achieve the best performance when using these selectors, first select some elements using a pure CSS selector, then use .filter().]]> + querySelectorAll() method. To achieve the best performance when using these selectors, first select some elements using a pure CSS selector, then use .filter().]]> @@ -302,116 +343,284 @@ jQuery.event.props.push( "dataTransfer" ); - jQuery 1.0 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - 1.0.1, 1.0.2, 1.0.3, 1.0.4. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.1 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.1.2 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.1.3 Release Notes - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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 +
    + ]]>
    - jQuery 1.1.4 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.2 Release Notes - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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 +
    + ]]>
    - 1.2.1, 1.2.2, 1.2.3. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.2.6 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - 1.3, 1.3.1, 1.3.2 - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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 +
    + ]]>
    - jQuery 1.4 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.4.1 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.4.2 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.4.3 Release Notes. - ]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    - jQuery 1.4.4 Release Notes.]]> + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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. +
    + ]]>
    Some APIs may have changed since this version was released. If using this version, find out about our version support.

    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.

    +
    ]]>
    - + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    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.

    +
    + ]]>
    - + Some APIs may have changed since this version was released. If using this version, find out about our version support. +

    All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.

    +
    + ]]>
    Aspects of the API that were changed in the corresponding version of jQuery. API changes in jQuery 1.7.0 dealt primarily with the new - Event APIs: .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 http://blog.jquery.com/2011/11/03/jquery-1-7-released/

    +
    Some APIs may have changed since this version was released. If using this version, find out about our version support.
    +

    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:

    +
      +
    • New event APIs: .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


    ]]>
    Aspects of the API that were changed 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 at http://blog.jquery.com/2012/08/09/jquery-1-8-released/

    +
    Some APIs may have changed since this version was released. If using this version, find out about our version support.
    +

    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


    ]]>
    Aspects of the API that were changed in the corresponding version of jQuery. Changes in jQuery 1.9 dealt primarily 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

    +
    Some APIs may have changed since this version was released. If using this version, find out about our version support.
    +

    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

    +
    + ]]>
    +
    + + Some APIs may have changed since these versions were released. If using either version, find out about our version support. +

    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.

    +
    + ]]>
    +
    + + Some APIs may have changed since these versions were released. If using either version, find out about our version support. +

    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.

    +
    + ]]>
    +
    + + Some APIs may have changed since these versions were released. If using either version, find out about our version support. +

    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.

    +
    + ]]>
    +
    + + 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.

    +
    + ]]>
    +
    + + All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.

    +

    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.

    +
    + ]]>
    +
    + + All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.

    +

    .addClass(), .removeClass() & .toggleClass() now work on arrays of classes; a few APIs were deprecated.

    +

    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.

    +

    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.

    +
    + ]]>
    +
    + + All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.

    +

    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.

    +
    + ]]>
    +
    + + All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.

    +

    Returning JSON even for JSONP erroneous responses is working again, a few focus fixes.

    +

    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.

    +

    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.

    +
    + ]]>
    +
    + + This is a pre-release. Behavior may change before 4.0.0 final is released. +

    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.


    ]]>
    diff --git a/config-sample.json b/config-sample.json index b26cf9fc..2a56329c 100644 --- a/config-sample.json +++ b/config-sample.json @@ -1,5 +1,5 @@ { - "url": "vagrant.api.jquery.com", - "username": "admin", - "password": "secret" + "url": "http://local.api.jquery.com", + "username": "dev", + "password": "dev" } diff --git a/docsearch.config.json b/docsearch.config.json new file mode 100644 index 00000000..f420af4a --- /dev/null +++ b/docsearch.config.json @@ -0,0 +1,52 @@ +{ + "index_name": "jquery_com", + "start_urls": [ + { "url": "https://api.jquery.com", "selectors_key": "api", "page_rank": 20 }, + { "url": "https://jquery.com", "page_rank": 10 } + ], + "stop_urls": [ + ".com/category/" + ], + "selectors": { + "default": { + "lvl0": { + "selector": "#menu-top .menu-item.current > a", + "global": true, + "default_value": "Documentation" + }, + "lvl1": "#content h1", + "lvl2": "#content h2", + "lvl3": "#content h3", + "lvl4": "#content h4", + "lvl5": "#content h5", + "text": "#content p, #content li, #content tr" + }, + "api": { + "lvl0": { + "selector": "#categories .cat-item.current-cat > a", + "global": true, + "default_value": "API" + }, + "lvl1": "#content h1", + "lvl2": "#content h2, #content h4.name", + "lvl3": "#content h3, #content h4:not(.name)", + "lvl4": "#content h5, #content strong:first-child", + "text": ".entry-content p, .entry-content li" + } + }, + "custom_settings": { + "token_separators": ["_", "-", "."] + }, + "selectors_exclude": [ + "header ~ article", + ".returns", + ".version-details", + ".section-title", + ".icon-link.toc-link", + "[class^=toclevel]", + "#toctitle", + ".desc strong:first-child" + ], + "min_indexed_level": 2, + "scrape_start_urls": false +} diff --git a/entries/add.xml b/entries/add.xml index 6f1d7870..bb95b0f0 100644 --- a/entries/add.xml +++ b/entries/add.xml @@ -20,7 +20,7 @@ - 1.3.2 + 1.1 An existing jQuery object to add to the set of matched elements. diff --git a/entries/addClass.xml b/entries/addClass.xml index 476251d8..39d6a0bf 100644 --- a/entries/addClass.xml +++ b/entries/addClass.xml @@ -7,6 +7,12 @@ One or more space-separated classes to be added to the class attribute of each matched element. + + 3.3 + + An array of classes to be added to the class attribute of each matched element. + + 1.4 @@ -16,9 +22,21 @@ + + 3.3 + + A function returning one or more space-separated class names or an array of class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + + + + + + Adds the specified class(es) to each element in the set of matched elements.

    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.

    +

    Before jQuery version 1.12/2.2, the .addClass() method manipulated the className property of the selected elements, not the class attribute. Once the property was changed, it was the browser that updated the attribute accordingly. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).

    +

    As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the class attribute is used instead. So, .addClass() can be used on XML or SVG documents.

    More than one class may be added at a time, separated by a space, to the set of matched elements, like so:

    
     $( "p" ).addClass( "myClass yourClass" );
    @@ -62,7 +80,30 @@ $( "p" ).last().addClass( "selected" );
       
         Add the classes "selected" and "highlight" to the matched elements.
         
    +    
    +    Hello

    +

    and

    +

    Goodbye

    +]]> +
    + + Add the classes "selected" and "highlight" to the matched elements (3.3+ syntax). + + + diff --git a/entries/after.xml b/entries/after.xml index 1e195510..2ea48a9c 100644 --- a/entries/after.xml +++ b/entries/after.xml @@ -4,16 +4,18 @@ 1.0 - HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + HTML string, DOM element, text node, array of elements and text nodes, or jQuery object to insert after each element in the set of matched elements. + - One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + One or more additional DOM elements, text nodes, arrays of elements and text nodes, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + @@ -21,24 +23,26 @@ 1.4 - A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + - - 1.10 - - A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + + 1.10-and-2.0 + + A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + @@ -92,7 +96,7 @@ $( "p" ).after(function() {

    Similar to other content-adding methods such as .prepend() and .before(), .after() also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.

    For example, the following will insert two new <div>s and an existing <div> after the first paragraph:

    
    -var $newdiv1 = $( "<div id='object1'/>" ),
    +var $newdiv1 = $( "<div id='object1'></div>" ),
       newdiv2 = document.createElement( "div" ),
       existingdiv1 = document.getElementById( "foo" );
     
    diff --git a/entries/ajaxComplete-shorthand.xml b/entries/ajaxComplete-shorthand.xml
    new file mode 100644
    index 00000000..3f44abc1
    --- /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 7f045973..0c133516 100644 --- a/entries/ajaxComplete.xml +++ b/entries/ajaxComplete.xml @@ -1,18 +1,24 @@ - - .ajaxComplete() + + ajaxComplete event + Register a handler to be called when Ajax requests complete. This is an AjaxEvent. - 1.0 - + 1.7 + + The string "ajaxComplete". + + 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.

    -

    As of jQuery 1.8, the .ajaxComplete() method should only be attached to document.

    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.

    +

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

    - + + Show a message when an Ajax request completes. Request Complete." ); -}); +} ); ]]> +
    diff --git a/entries/ajaxError-shorthand.xml b/entries/ajaxError-shorthand.xml new file mode 100644 index 00000000..f36ac54a --- /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 d13f71e6..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.

    -

    As of jQuery 1.8, the .ajaxError() method should only be attached to document.

    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. Error requesting page " + settings.url + "" ); -}); +} ); ]]> + diff --git a/entries/ajaxSend-shorthand.xml b/entries/ajaxSend-shorthand.xml new file mode 100644 index 00000000..a9ae031e --- /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 2d609b71..cbd1641c 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.

    -

    As of jQuery 1.8, the .ajaxSend() method should only be attached to document.

    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. Starting request at " + settings.url + "" ); -}); +} ); ]]> +
    diff --git a/entries/ajaxStart-shorthand.xml b/entries/ajaxStart-shorthand.xml new file mode 100644 index 00000000..51b2fc9e --- /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 7747e5b6..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.

    -

    As of jQuery 1.8, the .ajaxStart() method should only be attached to document.

    - + + 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..78121657 --- /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 76b3bffc..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.

    -

    As of jQuery 1.8, the .ajaxStop() method should only be attached to document.

    - + + 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..a9e54335 --- /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 26583e2e..8824a621 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.

    -

    As of jQuery 1.8, the .ajaxSuccess() method should only be attached to document.

    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: " +
    +    $( ".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.

    +

    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. Successful Request!" ); -}); +} ); ]]> +
    diff --git a/entries/andSelf.xml b/entries/andSelf.xml index 6870b479..967c72ef 100644 --- a/entries/andSelf.xml +++ b/entries/andSelf.xml @@ -1,78 +1,17 @@ - + .andSelf() 1.2 Add the previous set of elements on the stack to the current set. -

    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.

    +
    - - The .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

    -
    -
    -]]> -
    +
    diff --git a/entries/animate.xml b/entries/animate.xml index d05f366e..c4ac9e70 100644 --- a/entries/animate.xml +++ b/entries/animate.xml @@ -22,7 +22,7 @@

    The .animate() method allows us to create animation effects on any numeric CSS property. The only required parameter is a plain object of CSS properties. This object is similar to the one that can be sent to the .css() method, except that the range of properties is more restrictive.

    Animation Properties and Values

    -

    All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color() plugin is used). Property values are treated as a number of pixels unless otherwise specified. The units em and % can be specified where applicable.

    +

    All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color plugin is used). Property values are treated as a number of pixels unless otherwise specified. The units em and % can be specified where applicable.

    In addition to style properties, some non-style properties such as scrollTop and scrollLeft, as well as custom properties, can be animated.

    Shorthand CSS properties (e.g. font, background, border) are not fully supported. For example, if you want to animate the rendered border width, at least a border style and border width other than "auto" must be set in advance. Or, if you want to animate font size, you would use fontSize or the CSS equivalent 'font-size' rather than simply 'font'.

    In addition to numeric values, each property can take the strings 'show', 'hide', and 'toggle'. These shortcuts allow for custom hiding and showing animations that take into account the display type of the element. In order to use jQuery's built-in toggle state tracking, the 'toggle' keyword must be consistently given as the value of the property being animated.

    @@ -32,8 +32,8 @@

    Duration

    Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The default duration is 400 milliseconds. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    -

    Complete Function

    -

    If supplied, the complete callback function is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, the callback is executed once per matched element, not once for the animation as a whole.

    +

    Callback Functions

    +

    If supplied, the start, step, progress, complete, done, fail, and always callbacks are called on a per-element basis; this is set to the DOM element being animated. If no elements are in the set, no callbacks are called. If multiple elements are animated, the callback is executed once per matched element, not once for the animation as a whole. Use the .promise() method to obtain a promise to which you can attach callbacks that fire once for an animated set of any size, including zero elements.

    Basic Usage

    To animate any element, such as a simple image:

    
    @@ -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",
    @@ -56,20 +56,26 @@ $( "#clickme" ).click(function() {
     });
         

    - +

    + +
    Figure 1 - Illustration of the specified animation effect
    +

    Note that the target value of the height property is 'toggle'. Since the image was visible before, the animation shrinks the height to 0 to hide it. A second click then reverses this transition:

    - +

    + +
    Figure 2 - Illustration of the specified animation effect
    +

    The opacity of the image is already at its target value, so this property is not animated by the second click. Since the target value for left is a relative value, the image moves even farther to the right during this second animation.

    Directional properties (top, right, bottom, left) have no discernible effect on elements if their position style property is static, which it is by default.

    -

    Note: The jQuery UI project extends the .animate() method by allowing some non-numeric styles such as colors to be animated. The project also includes mechanisms for specifying animations through CSS classes rather than individual attributes.

    +

    Note: The jQuery UI project extends the .animate() method by allowing some non-numeric styles such as colors to be animated. The project also includes mechanisms for specifying animations through CSS classes rather than individual attributes.

    -

    Note: if attempting to animate an element with a height or width of 0px, where contents of the element are visible due to overflow, jQuery may clip this overflow during animation. By fixing the dimensions of the original element being hidden however, it is possible to ensure that the animation runs smoothly. A clearfix can be used to automatically fix the dimensions of your main element without the need to set this manually.

    +

    Note: if attempting to animate an element with a height or width of 0px, where contents of the element are visible due to overflow, jQuery may clip this overflow during animation. By fixing the dimensions of the original element being hidden however, it is possible to ensure that the animation runs smoothly. A clearfix can be used to automatically fix the dimensions of your main element without the need to set this manually.

    Step Function

    The second version of .animate() provides a step option — a callback function that is fired at each step of the animation. This function is useful for enabling custom animation types or altering the animation as it is occurring. It accepts two arguments (now and fx), and this is set to the DOM element being animated.

    @@ -90,12 +96,12 @@ $( "li" ).animate({ });

    Easing

    -

    The remaining parameter of .animate() is a string naming an easing function to use. An easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    The remaining parameter of .animate() is a string naming an easing function to use. An easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Per-property Easing

    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" ],
    @@ -107,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"
    @@ -131,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.
         
    @@ -185,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.
         
         1.0
         
    -      DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements.
    +      DOM element, text node, array of elements and text nodes, HTML string, or jQuery object to insert at the end of each element in the set of matched elements.
           
           
    +      
           
           
         
         
    -      One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements.
    +      One or more additional DOM elements, text nodes, arrays of elements and text nodes, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements.
           
           
    +      
           
           
         
    @@ -21,19 +23,20 @@
       
         1.4
         
    -      A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set.
    +      A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set.
           
           
           
             
             
    +        
                     
           
         
       
       Insert content, specified by the parameter, to the end of each element in the set of matched elements.
       
    -    

    The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend()).

    +

    The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend()).

    The .append() and .appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target. With .append(), the selector expression preceding the method is the container into which the content is inserted. With .appendTo(), on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted into the target container.

    Consider the following HTML:

    
    @@ -78,7 +81,7 @@ $( ".container" ).append( $( "h2" ) );
         

    Similar to other content-adding methods such as .prepend() and .before(), .append() also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.

    For example, the following will insert two new <div>s and an existing <div> as the last three child nodes of the body:

    
    -var $newdiv1 = $( "<div id='object1'/>" ),
    +var $newdiv1 = $( "<div id='object1'></div>" ),
       newdiv2 = document.createElement( "div" ),
       existingdiv1 = document.getElementById( "foo" );
     
    @@ -87,6 +90,7 @@ $( "body" ).append( $newdiv1, [ newdiv2, existingdiv1 ] );
         

    Since .append() can accept any number of additional arguments, the same result can be achieved by passing in the three <div>s as three separate arguments, like so: $('body').append( $newdiv1, newdiv2, existingdiv1 ). The type and number of arguments will largely depend on how you collect the elements in your code.

    + Appends some HTML to all paragraphs.

    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.

    + Append all spans to the element with the ID "foo" (Check append() documentation for more examples) Note: Attribute values are strings with the exception of a few attributes such as value and tabindex.

    As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the checked, selected, or disabled state of form elements, use the .prop() method.

    +

    Attributes vs. Properties

    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:

    - + - + - +
    @@ -43,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
    @@ -68,7 +69,7 @@

    -

    According to the W3C forms specification, the checked attribute is a boolean attribute, which means the corresponding property is true if the attribute is present at all—even if, for example, the attribute has no value or is set to empty string value or even "false". This is true of all boolean attributes.

    +

    According to the W3C forms specification, the checked attribute is a boolean attribute, which means the corresponding property is true if the attribute is present at all—even if, for example, the attribute has no value or is set to empty string value or even "false". This is true of all boolean attributes.

    Nevertheless, the most important concept to remember about the checked attribute is that it does not correspond to the checked property. The attribute actually corresponds to the defaultChecked property and should be used only to set the initial value of the checkbox. The checked attribute value does not change with the state of the checkbox, while the checked property does. Therefore, the cross-browser-compatible way to determine if a checkbox is checked is to use the property:

    • @@ -88,13 +89,13 @@ Display the checked attribute and property of a checkbox as it changes. " + $input.attr( "checked" ) + "
      " + ".prop( 'checked' ): " + $input.prop( "checked" ) + "
      " + ".is( ':checked' ): " + $input.is( ":checked" ) + "" ); - }) - .change(); + } ) + .trigger( "change" ); ]]>
      + @@ -147,7 +149,9 @@ The title of the emphasis is:
      - A value to set for the attribute. + + + A value to set for the attribute. If null, the specified attribute will be removed (as in .removeAttr()). Non-ARIA attributes can also be removed by passing false.
      @@ -167,7 +171,7 @@ The title of the emphasis is:
      - +
      @@ -193,6 +197,11 @@ $( "#greatphoto" ).attr({ });

    When setting multiple attributes, the quotes around attribute names are optional.

    +

    Removing an attribute

    +

    To remove an attribute, either call .attr( name, null ) or use .removeAttr( name ). For non-ARIA attributes, in jQuery 4.0+ you can also call .attr( name, false ).

    +
    +

    Note: Because ARIA attributes frequently associate behavior with "false" values that differs from attribute absence, passing false as the value for an attribute whose name starts with "aria-…" will stringify that value to "false" rather than remove the attribute. To guarantee removal of an attribute, use the .removeAttr() method or provide null as the value to the .attr() setter.

    +

    WARNING: When setting the 'class' attribute, you must always use quotes!

    Note: Attempting to change the type attribute on an input or button element created via document.createElement() will throw an exception on Internet Explorer 8 or older.

    @@ -278,5 +287,6 @@ $( "img" ).attr( "src", function() { + diff --git a/entries/attribute-contains-prefix-selector.xml b/entries/attribute-contains-prefix-selector.xml index 4b706bc6..3465e6c2 100644 --- a/entries/attribute-contains-prefix-selector.xml +++ b/entries/attribute-contains-prefix-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-). diff --git a/entries/attribute-contains-selector.xml b/entries/attribute-contains-selector.xml index 8cb21dfc..15e7778d 100644 --- a/entries/attribute-contains-selector.xml +++ b/entries/attribute-contains-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value containing a given substring. diff --git a/entries/attribute-contains-word-selector.xml b/entries/attribute-contains-word-selector.xml index 18df4cbc..8a71f37b 100644 --- a/entries/attribute-contains-word-selector.xml +++ b/entries/attribute-contains-word-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value containing a given word, delimited by spaces. diff --git a/entries/attribute-ends-with-selector.xml b/entries/attribute-ends-with-selector.xml index 0febbde7..cbdfe808 100644 --- a/entries/attribute-ends-with-selector.xml +++ b/entries/attribute-ends-with-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive. diff --git a/entries/attribute-equals-selector.xml b/entries/attribute-equals-selector.xml index 555cf7c9..faa6e513 100644 --- a/entries/attribute-equals-selector.xml +++ b/entries/attribute-equals-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value exactly equal to a certain value. diff --git a/entries/attribute-not-equal-selector.xml b/entries/attribute-not-equal-selector.xml index fabb6a2e..38531ffc 100644 --- a/entries/attribute-not-equal-selector.xml +++ b/entries/attribute-not-equal-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value. diff --git a/entries/attribute-starts-with-selector.xml b/entries/attribute-starts-with-selector.xml index 3c2f6912..54067652 100644 --- a/entries/attribute-starts-with-selector.xml +++ b/entries/attribute-starts-with-selector.xml @@ -8,7 +8,7 @@ An attribute name. - An attribute value. Can be either an unquoted single word or a quoted string. + An attribute value. Can be either a valid identifier or a quoted string. Selects elements that have the specified attribute with a value beginning exactly with a given string. diff --git a/entries/before.xml b/entries/before.xml index cba817a9..577f588b 100644 --- a/entries/before.xml +++ b/entries/before.xml @@ -4,16 +4,18 @@ 1.0 - HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + HTML string, DOM element, text node, array of elements and text nodes, or jQuery object to insert before each element in the set of matched elements. + - One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + One or more additional DOM elements, text nodes, arrays of elements and text nodes, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + @@ -25,23 +27,25 @@ + - A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. - 1.10 - + 1.10-and-2.0 + + - A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. @@ -87,7 +91,7 @@ $( ".container" ).before( $( "h2" ) );

    Similar to other content-adding methods such as .prepend() and .after(), .before() also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.

    For example, the following will insert two new <div>s and an existing <div> before the first paragraph:

    
    -var newdiv1 = $( "<div id='object1'/>" ),
    +var newdiv1 = $( "<div id='object1'></div>" ),
       newdiv2 = document.createElement( "div" ),
       existingdiv1 = document.getElementById( "foo" );
     
    diff --git a/entries/bind.xml b/entries/bind.xml
    index a81e46a8..aa45c455 100644
    --- a/entries/bind.xml
    +++ b/entries/bind.xml
    @@ -1,5 +1,5 @@
     
    -
    +
       .bind()
       
         1.0
    @@ -34,10 +34,10 @@
       
       Attach a handler to an event for the elements.
       
    -    

    As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document. For earlier versions, the .bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind() occurs. For more flexible event binding, see the discussion of event delegation in .on() or .delegate().

    +

    As of jQuery 3.0, .bind() has been deprecated. It was superseded by the .on() method for attaching event handlers to a document since jQuery 1.7, so its use was already discouraged. For earlier versions, the .bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind() occurs. For more flexible event binding, see the discussion of event delegation in .on().

    Any string is legal for eventType; if the string is not the name of a native DOM event, then the handler is bound to a custom event. These events are never called by the browser, but may be triggered manually from other JavaScript code using .trigger() or .triggerHandler().

    If the eventType string contains a period (.) character, then the event is namespaced. The period character separates the event from its namespace. For example, in the call .bind( "click.name", handler ), the string click is the event type, and the string name is the namespace. Namespacing allows us to unbind or trigger some events of a type without affecting others. See the discussion of .unbind() for more information.

    -

    There are shorthand methods for some standard browser events such as .click() that can be used to attach or trigger event handlers. For a complete list of shorthand methods, see the events category.

    +

    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 .bind() is:

    
    @@ -221,7 +221,7 @@ $( "p" ).bind( "myCustomEvent", function( e, myName, myValue ) {
         .fadeIn( 30 )
         .fadeOut( 1000 );
       });
    -$( "button" ).click(function() {
    +$( "button" ).on( "click", function() {
       $( "p" ).trigger( "myCustomEvent", [ "John" ] );
     });
     ]]>
    @@ -259,4 +259,5 @@ $( "div.test" ).bind({
       
       
       
    +  
     
    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 747a7d1e..68636a0c 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,32 +32,55 @@
     <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.

    +

    The native blur event is asynchronous in all versions of IE, contrary to other browsers. To avoid issues related to this discrepancy, as of jQuery 3.7.0, jQuery uses focusout as the native backing event for blur in IE.

    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(); -}); +} ); ]]>
    The argument or list of arguments to pass back to the callback list. - Call all of the callbacks with the given arguments + Call all of the callbacks with the given arguments.

    This method returns the Callbacks object onto which it is attached (this).

    diff --git a/entries/callbacks.fireWith.xml b/entries/callbacks.fireWith.xml index dfb2adb3..7527e182 100644 --- a/entries/callbacks.fireWith.xml +++ b/entries/callbacks.fireWith.xml @@ -3,11 +3,11 @@ callbacks.fireWith() 1.7 - + A reference to the context in which the callbacks in the list should be fired. - - An argument, or array of arguments, to pass to the callbacks in the list. + + An array or array-like object of arguments to pass to the callbacks in the list. If omitted or undefined, no arguments will be passed. Call all callbacks in a list with the given context and arguments. diff --git a/entries/change-shorthand.xml b/entries/change-shorthand.xml new file mode 100644 index 00000000..98d9509a --- /dev/null +++ b/entries/change-shorthand.xml @@ -0,0 +1,36 @@ + + + .change() + Bind an event handler to the "change" 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 .change( handler ) or .change( eventData, handler ), use .on( "change", handler ) or .on( "change", eventData, handler ), respectively.

    +

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

    +
    +
    + + + + +
    diff --git a/entries/change.xml b/entries/change.xml index 97a9b5e7..e179c506 100644 --- a/entries/change.xml +++ b/entries/change.xml @@ -1,16 +1,15 @@ - - .change() - Bind an event handler to the "change" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "change" event, or trigger that event on an element. + + + change event + Bind an event handler to the "change" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "change". - - - 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( "change", handler ) in the first two variations, and .trigger( "change" ) in the third.

    +
    +

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

    +

    The change event is sent to an element when its value changes. This event is limited to <input> elements, <textarea> boxes and <select> elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

    For example, consider the HTML:

    
    @@ -40,34 +38,34 @@
         

    The event handler can be bound to the text input and the select box:

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

    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 .change() without arguments:

    +

    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 .trigger( "change" ):

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

    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 change event on both of the form elements.

    As of jQuery 1.4, the change event bubbles in Internet Explorer, behaving consistently with the event in other modern browsers.

    -

    Note: Changing the value of an input element using JavaScript, using .val() for example, won't fire the event.

    +

    Note: Changing the value of an input element using JavaScript, using .val() for example, won't fire the event.

    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. To add a validity test to all text input elements: - + +
    + + + 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(); -}); +} ); ]]>
    Matches all elements that are checked or selected. -

    The :checked selector works for checkboxes, radio buttons, and select elements. For select elements only, use the :selected selector.

    +

    The :checked selector works for checkboxes, radio buttons, and options of select elements.

    +

    To retrieve only the selected options of select elements, use the :selected selector.

    Determine how many input elements are checked. diff --git a/entries/child-selector.xml b/entries/child-selector.xml index 5016a1b3..1b1b27c2 100644 --- a/entries/child-selector.xml +++ b/entries/child-selector.xml @@ -13,7 +13,6 @@ Selects all direct child elements specified by "child" of elements specified by "parent". -

    As a CSS selector, the child combinator is supported by all modern web browsers including Safari, Firefox, Opera, Chrome, and Internet Explorer 7 and above, but notably not by Internet Explorer versions 6 and below. However, in jQuery, this selector (along with all others) works across all supported browsers, including IE6.

    The child combinator (E > F) can be thought of as a more specific form of the descendant combinator (E F) in that it selects only first-level descendants.

    diff --git a/entries/children.xml b/entries/children.xml index 8437acc5..5880351b 100644 --- a/entries/children.xml +++ b/entries/children.xml @@ -38,16 +38,16 @@ Find all children of the clicked element. Empty the queue. + + .click() + Bind an event handler to the "click" 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 .click( handler ) or .click( eventData, handler ), use .on( "click", handler ) or .on( "click", eventData, handler ), respectively.

    +

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

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

    This method is a shortcut for .on( "click", handler ) in the first two variations, and .trigger( "click" ) in the third. - The click event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event. +

    +

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

    +
    +

    The click event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event. For example, consider the HTML:

    
     <div id="target">
    @@ -34,24 +32,25 @@
       Trigger the handler
     </div>
         
    -

    +

    -

    +
    Figure 1 - Illustration of the rendered HTML
    +

    The event handler can be bound to any <div>:

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

    Now if we click on this element, the alert is displayed:

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

    We can also trigger the event when a different element is clicked:

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

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

    The click event is only triggered after this exact series of events:

    @@ -64,9 +63,9 @@ $( "#other" ).click(function() { Hide paragraphs on a page when they are clicked: - 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/clone.xml b/entries/clone.xml index 91d7bc29..764b6668 100644 --- a/entries/clone.xml +++ b/entries/clone.xml @@ -63,7 +63,7 @@ $( ".hello" ).clone().appendTo( ".goodbye" );

    However, objects and arrays within element data are not copied and will continue to be shared between the cloned element and the original element. To deep copy all data, copy each one manually:

    
     // Original element with attached data
    -var $elem = $( "#elem" ).data( "arr": [ 1 ] ),
    +var $elem = $( "#elem" ).data( "arr", [ 1 ] ),
         $clone = $elem.clone( true )
           // Deep copy to prevent data sharing
           .data( "arr", $.extend( [], $elem.data( "arr" ) ) );
    diff --git a/entries/closest.xml b/entries/closest.xml
    index 5f1bb2b4..903ba1a7 100644
    --- a/entries/closest.xml
    +++ b/entries/closest.xml
    @@ -14,7 +14,7 @@
             A string containing a selector expression to match elements against.
           
           
    -        A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead.
    +        A DOM element within which a matching element may be found.
           
         
         
    @@ -109,7 +109,7 @@ $( "li.item-a" )
           Show how event delegation can be done with closest. The closest list element toggles a yellow background when it or its descendent is clicked.
           
           
    @@ -134,7 +134,7 @@ $( document ).on( "click", function( event ) {
           
           
    @@ -166,7 +166,7 @@ $( document ).on( "click", function( event ) {
             An array or string containing a selector expression to match elements against (can also be a jQuery object).
           
           
    -        A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead.
    +        A DOM element within which a matching element may be found.
           
         
         Get an array of all the elements and selectors matched against the current element up through the DOM tree.
    diff --git a/entries/contains-selector.xml b/entries/contains-selector.xml
    index e1488269..c471083f 100644
    --- a/entries/contains-selector.xml
    +++ b/entries/contains-selector.xml
    @@ -25,5 +25,6 @@ $( "div:contains('John')" ).css( "text-decoration", "underline" );
     ]]>
       
       
    +  
       
     
    diff --git a/entries/contents.xml b/entries/contents.xml
    index 9f4d8b2f..6cfa73ba 100644
    --- a/entries/contents.xml
    +++ b/entries/contents.xml
    @@ -6,8 +6,9 @@
       
       Get the children of each element in the set of matched elements, including text and comment nodes.
       
    -    

    Given a jQuery object that represents a set of DOM elements, the .contents() method allows us to search through the immediate children of these elements in the DOM tree and construct a new jQuery object from the matching elements. The .contents() and .children() methods are similar, except that the former includes text nodes as well as HTML elements in the resulting jQuery object.

    +

    Given a jQuery object that represents a set of DOM elements, the .contents() method allows us to search through the immediate children of these elements in the DOM tree and construct a new jQuery object from the matching elements. The .contents() and .children() methods are similar, except that the former includes text nodes and comment nodes as well as HTML elements in the resulting jQuery object. Please note that most jQuery operations don't support text nodes and comment nodes. The few that do will have an explicit note on their API documentation page.

    The .contents() method can also be used to get the content document of an iframe, if the iframe is on the same domain as the main page.

    +

    As of jQuery 3.2, .contents() returns contents of <template> elements as well.

    Consider a simple <div> with a number of text nodes, each of which is separated by two line break elements (<br>):

    
     <div class="container">
    @@ -33,7 +34,7 @@ $( ".container" )
         .filter( "br" )
         .remove();
         
    -

    This code first retrieves the contents of <div class="container"> and then filters it for text nodes, which are wrapped in paragraph tags. This is accomplished by testing the .nodeType property of the element. This DOM property holds a numeric code indicating the node's type; text nodes use the code 3. The contents are again filtered, this time for <br /> elements, and these elements are removed.

    +

    This code first retrieves the contents of <div class="container"> and then filters it for text nodes, which are wrapped in paragraph tags. This is accomplished by testing the .nodeType property of the element. This DOM property holds a numeric code indicating the node's type; text nodes use the code 3. The contents are again filtered, this time for <br /> elements, and these elements are removed.

    Find all the text nodes inside a paragraph and wrap them with a bold tag. @@ -46,18 +47,19 @@ $( "p" ) .wrap( "" ); ]]>
    Hello John, how are you doing?

    +

    Hello John, how are you doing?

    ]]> - Change the background colour of links inside of an iframe. + Change the background color of links inside of an iframe. + ]]> + diff --git a/entries/context.xml b/entries/context.xml index a7377fa1..cd9c3cc4 100644 --- a/entries/context.xml +++ b/entries/context.xml @@ -1,12 +1,14 @@ - + .context 1.3 The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. -

    The .context property was deprecated in jQuery 1.10 and is only maintained to the extent needed for supporting .live() in the jQuery Migrate plugin. It may be removed without notice in a future version.

    +
    +

    Note: This API has been removed in jQuery 3.0.

    +

    The .live() method for binding event handlers uses this property to determine the root element to use for its event delegation needs.

    The value of this property is typically equal to document, as this is the default context for jQuery objects if none is supplied. The context may differ if, for example, the object was created by searching within an <iframe> or XML document.

    Note that the context property may only apply to the elements originally selected by jQuery(), as it is possible for the user to add elements to the collection via methods such as .add() and these may have a different context.

    @@ -18,12 +20,10 @@ $( "ul" ) .append( "
  • " + $( "ul" ).context + "
  • " ) .append( "
  • " + $( "ul", document.body ).context.nodeName + "
  • " ); ]]>
    -
-]]> - + + 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 new file mode 100644 index 00000000..63d9c179 --- /dev/null +++ b/entries/contextmenu.xml @@ -0,0 +1,105 @@ + + +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 + + 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. + + + + +
+

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">
+  Right-click here
+</div>
+    
+

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

+

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

Now right-clicking on this element displays the alert:

+

+ Handler for `contextmenu` called. +

+

To trigger the event manually, use .trigger( "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. + + + +Right click the block +]]> + + + + +
+ + + contextmenu event + Trigger the "contextmenu" event on an element. + + 1.0 + + The string "contextmenu". + + + +

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

+
+ + +
+ +
diff --git a/entries/css.xml b/entries/css.xml index 8fe89b20..85a304e8 100644 --- a/entries/css.xml +++ b/entries/css.xml @@ -17,17 +17,18 @@ Get the computed style properties for the first element in the set of matched elements. -

The .css() method is a convenient way to get a computed style property from the first matched element, especially in light of the different ways browsers access most of those properties (the getComputedStyle() method in standards-based browsers versus the currentStyle and runtimeStyle properties in Internet Explorer) and the different terms browsers use for certain properties. For example, Internet Explorer's DOM implementation refers to the float property as styleFloat, while W3C standards-compliant browsers refer to it as cssFloat. For consistency, you can simply use "float", and jQuery will translate it to the correct value for each browser.

+

The .css() method is a convenient way to get a computed style property from the first matched element, especially in light of the different ways browsers access most of those properties (the getComputedStyle() method in standards-based browsers versus the currentStyle and runtimeStyle properties in Internet Explorer prior to version 9) and the different terms browsers use for certain properties. For example, Internet Explorer's DOM implementation refers to the float property as styleFloat, while W3C standards-compliant browsers refer to it as cssFloat. For consistency, you can simply use "float", and jQuery will translate it to the correct value for each browser.

Also, jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. For example, jQuery understands and returns the correct value for both .css( "background-color" ) and .css( "backgroundColor" ). This means mixed case has a special meaning, .css( "WiDtH" ) won't do the same as .css( "width" ), for example.

-

Note that the computed style of an element may not be the same as the value specified for that element in a style sheet. For example, computed styles of dimensions are almost always pixels, but they can be specified as em, ex, px or % in a style sheet. Different browsers may return CSS color values that are logically but not textually equal, e.g., #FFF, #ffffff, and rgb(255,255,255).

+

Note that the computed style of an element may not be the same as the value specified for that element in a style sheet. For example, computed styles of dimensions are almost always pixels, but they can be specified as em, ex, px or % in a style sheet. Different browsers may return CSS color values that are logically but not textually equal, e.g., #FFF, #ffffff, and rgb(255,255,255).

Retrieval of shorthand CSS properties (e.g., margin, background, border), although functional with some browsers, is not guaranteed. For example, if you want to retrieve the rendered border-width, use: $( elem ).css( "borderTopWidth" ), $( elem ).css( "borderBottomWidth" ), and so on.

An element should be connected to the DOM when calling .css() on it. If it isn't, jQuery may throw an error.

As of jQuery 1.9, passing an array of style properties to .css() will result in an object of property-value pairs. For example, to retrieve all four rendered border-width values, you could use $( elem ).css([ "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth" ]).

+

As of jQuery 3.2, CSS Custom Properties (also called CSS Variables) are supported: $( "p" ).css( "--custom-property" ). Note that you need to provide the property name as-is, camelCasing it won't work as it does for regular CSS properties.

Get the background color of a clicked div. " + color + "." ); @@ -53,7 +54,7 @@ $( "div" ).click(function() { Get the width, height, text color, and background color of a clicked div. + + @@ -128,7 +131,7 @@ $( "div" ).click(function() { A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. - + @@ -144,8 +147,17 @@ $( "div" ).click(function() {

As with the .prop() method, the .css() method makes setting properties of elements quick and easy. This method can take either a property name and value as separate parameters, or a single object of key-value pairs.

Also, jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. For example, jQuery understands and returns the correct value for both .css({ "background-color": "#ffe", "border-left": "5px solid #ccc" }) and .css({backgroundColor: "#ffe", borderLeft: "5px solid #ccc" }). Notice that with the DOM notation, quotation marks around the property names are optional, but with CSS notation they're required due to the hyphen in the name.

-

When a number is passed as the value, jQuery will convert it to a string and add px to the end of that string. If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method.

+

In jQuery 3.x or older, when a number is passed as the value, jQuery will convert it to a string and add px to the end of that string. However, there are exceptions. px is not added to keys of jQuery.cssNumber If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method.

+

In jQuery 4.0 or newer, when a number is passed as the value, jQuery will only convert it to a string and add px to the end of that string for a limited set of properties - mostly related to width, height, border, margin & padding; the full list:

+
    +
  • setting the element position: top, right, bottom, left
  • +
  • setting the element dimensions: width, height, min-width, min-height, max-width, max-height
  • +
  • padding-related: padding, padding-top, padding-right, padding-bottom, padding-left
  • +
  • margin-related: margin, margin-top, margin-right, margin-bottom, margin-left
  • +
  • border-related: border, border-width, border-top, border-top-width, border-right, border-right-width, border-bottom, border-bottom-width, border-left, border-left-width
  • +

When using .css() as a setter, jQuery modifies the element's style property. For example, $( "#mydiv" ).css( "color", "green" ) is equivalent to document.getElementById( "mydiv" ).style.color = "green". Setting the value of a style property to an empty string — e.g. $( "#mydiv" ).css( "color", "" ) — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. As a consequence, the element's style for that property will be restored to whatever value was applied. So, this method can be used to cancel any style modification you have previously performed. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element. Warning: one notable exception is that, for IE 8 and below, removing a shorthand property such as border or background will remove that style entirely from the element, regardless of what is set in a stylesheet or <style> element.

+

Note: .css() doesn't support !important declarations. So, the statement $( "p" ).css( "color", "red !important" ) does not turn the color of all paragraphs in the page to red as of jQuery 3.6.0. Do not depend on that not working, though, as a future version of jQuery may add support for such declarations. It's strongly advised to use classes instead; otherwise use a jQuery plugin.

As of jQuery 1.8, the .css() setter will automatically take care of prefixing the property name. For example, take .css( "user-select", "none" ) in Chrome/Safari will set it as -webkit-user-select, Firefox will use -moz-user-select, and IE10 will use -ms-user-select.

As of jQuery 1.6, .css() accepts relative values similar to .animate(). Relative values are a string starting with += or -= to increment or decrement the current value. For example, if an element's padding-left was 10px, .css( "padding-left", "+=15" ) would result in a total padding-left of 25px.

As of jQuery 1.4, .css() allows us to pass a function as the property value:

@@ -156,6 +168,7 @@ $( "div.example" ).css( "width", function( index ) {

This example sets the widths of the matched elements to incrementally larger values.

Note: If nothing is returned in the setter function (ie. function( index, style ){} ), or if undefined is returned, the current value is not changed. This is useful for selectively setting values only when certain criteria are met.

+

As of jQuery 3.2, CSS Custom Properties (also called CSS Variables) are supported: $( "p" ).css( "--custom-property", "value" ). Note that you need to provide the property name as-is, camelCasing it won't work as it does for regular CSS properties.

Change the color of any paragraph to red on mouseover event. @@ -281,5 +294,7 @@ $( "div" ).on( "click", function() { + + diff --git a/entries/data.xml b/entries/data.xml index f54a229c..d998d38c 100644 --- a/entries/data.xml +++ b/entries/data.xml @@ -24,13 +24,14 @@

We can set several distinct values for a single element and retrieve them later:


 $( "body" ).data( "foo", 52 );
-$( "body" ).data( "bar", { myType: "test", count: 40 } );
+$( "body" ).data( "bar", { isManual: true } );
 $( "body" ).data( { baz: [ 1, 2, 3 ] } );
 $( "body" ).data( "foo" ); // 52
-$( "body" ).data(); // { foo: 52, bar: { myType: "test", count: 40 }, baz: [ 1, 2, 3 ] }
+$( "body" ).data(); // { foo: 52, bar: { isManual: true }, baz: [ 1, 2, 3 ] }
       
-

In jQuery 1.4.3 setting an element's data object with .data(obj) extends the data previously stored with that element.

-

Prior to jQuery 1.4.3 (starting in jQuery 1.4) the .data() method completely replaced all data, instead of just extending the data object. If you are using third-party plugins it may not be advisable to completely replace the element's data object, since plugins may have also set data.

+

Using the data() method to update data does not affect attributes in the DOM. To set a data-* attribute value, use attr.

+

Prior to jQuery 1.4.3, .data( obj ) completely replaced all data. Since jQuery 1.4.3, data is instead extended by shallow merge.

+

Since jQuery 3, every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter in a key is replaced by the uppercase version of the letter, in alignment with the HTML dataset API. A statement like $( "body" ).data( { "my-name": "aValue" } ).data(); will return { myName: "aValue" }.

Due to the way browsers interact with plugins and external code, the .data() method cannot be used on <object> (unless it's a Flash plugin), <applet> or <embed> elements.

@@ -39,8 +40,8 @@ $( "body" ).data(); // { foo: 52, bar: { myType: "test", count: 40 }, baz: [ 1, Store then retrieve a value from the div element. 1.4 - Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + Return arbitrary data associated with the first element in the jQuery collection, as set by data() or by an HTML5 data-* attribute. -

The .data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks. We can retrieve several distinct values for a single element one at a time, or as a set:

+

The .data() method allows us to read data previously associated with DOM elements. We can retrieve several distinct values for a single element one at a time, or as a set:


-alert( $( "body" ).data( "foo" ) );
-alert( $( "body" ).data() );
-      
-

The above lines alert the data values that were set on the body element. If no data at all was set on that element, undefined is returned.

-

-alert( $( "body" ).data( "foo" ) ); // undefined
-$( "body" ).data( "bar", "foobar" );
-alert( $( "body" ).data( "bar" ) ); // foobar
+var elem = document.createElement( "span" );
+$( elem ).data( "foo" ); // undefined
+$( elem ).data(); // {}
+
+$( elem ).data( "foo", 42 );
+$( elem ).data( "foo" ); // 42
+$( elem ).data(); // { foo: 42 }
       
+

Calling .data() with no parameters returns a JavaScript object containing each stored value as a property. The object can be used directly to get data values (but note that property names originally containing dashes will have been modified as described below).

+

Since jQuery 3, every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter in a key is replaced by the uppercase version of the letter, in alignment with the HTML dataset API. A statement like $( "body" ).data( { "my-name": "aValue" } ).data(); will return { myName: "aValue" }.

- HTML5 data-* Attributes + HTML5 data-* Attributes

-

As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery's data object. The treatment of attributes with embedded dashes was changed in jQuery 1.6 to conform to the W3C HTML5 specification.

+

Since jQuery 1.4.3, data-* attributes are used to initialize jQuery data. An element's data-* attributes are retrieved the first time the data() method is invoked upon it, and then are no longer accessed or mutated (all values are stored internally by jQuery).

+

Every attempt is made to convert the attribute's string value to a JavaScript value (this includes booleans, numbers, objects, arrays, and null). A string is only converted to a number if doing so doesn't change its representation (for example, the string "100" is converted to the number 100, but "1E02" and "100.000" are left as strings because their numeric value of 100 serializes to "100"). When a string starts with '{' or '[', then jQuery.parseJSON is used to parse it; it must follow valid JSON syntax including quoted property names. A string not parseable as a JavaScript value is not converted.

+

To retrieve a data-* attribute value as an unconverted string, use the attr() method.

+

Since jQuery 1.6, dashes in data-* attribute names have been processed in alignment with the HTML dataset API.

For example, given the following HTML:

<div data-role="page" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>
-

All of the following jQuery code will work.

+

The following comparisons are all true:


 $( "div" ).data( "role" ) === "page";
 $( "div" ).data( "lastValue" ) === 43;
 $( "div" ).data( "hidden" ) === true;
 $( "div" ).data( "options" ).name === "John";
       
-

The second statement of the code above correctly refers to the data-last-value attribute of the element. In case no data is stored with the passed key, jQuery searches among the attributes of the element, converting a camel-cased string into a dashed string and then prepending data- to the result. So, the string lastValue is converted to data-last-value.

-

Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null). A value is only converted to a number if doing so doesn't change the value's representation. For example, "1E02" and "100.000" are equivalent as numbers (numeric value 100) but converting them would alter their representation so they are left as strings. The string value "100" is converted to the number 100.

-

When the data attribute is an object (starts with '{') or array (starts with '[') then jQuery.parseJSON is used to parse the string; it must follow valid JSON syntax including quoted property names. If the value isn't parseable as a JavaScript value, it is left as a string.

-

To retrieve the value's attribute as a string without any attempt to convert it, use the attr() method.

-

The data- attributes are pulled in the first time the data property is accessed and then are no longer accessed or mutated (all data values are then stored internally in jQuery).

-

Calling .data() with no parameters retrieves all of the values as a JavaScript object. This object can be safely cached in a variable as long as a new object is not set with .data(obj). Using the object directly to get or set values is faster than making individual calls to .data() to get or set each value:

-

-var mydata = $( "#mydiv" ).data();
-if ( mydata.count < 9 ) {
-  mydata.count = 43;
-  mydata.status = "embiggened";
-}
-    
Get the data named "blah" stored at for an element. + + .dblclick() + Bind an event handler to the "dblclick" 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 .dblclick( handler ) or .dblclick( eventData, handler ), use .on( "dblclick", handler ) or .on( "dblclick", eventData, handler ), respectively.

+

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

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

This method is a shortcut for .on( "dblclick", handler) in the first two variations, and .trigger( "dblclick" ) in the third. - The dblclick event is sent to an element when the element is double-clicked. Any HTML element can receive this event. +

+

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

+
+

The dblclick event is sent to an element when the element is double-clicked. Any HTML element can receive this event. For example, consider the HTML:


 <div id="target">
@@ -34,24 +32,25 @@
   Trigger the handler
 </div>
     
-

+

-

+
Figure 1 - Illustration of the rendered HTML
+

The event handler can be bound to any <div>:


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

Now double-clicking on this element displays the alert:

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

-

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

+

To trigger the event manually, call .trigger( "dblclick" ):


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

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

The dblclick event is only triggered after this exact series of events:

@@ -65,20 +64,20 @@ $( "#other" ).click(function() {

- To bind a "Hello World!" alert box the dblclick event on every paragraph on the page: + To bind a "Hello World!" alert box to the dblclick event on every paragraph on the page: Double click to toggle background color. - + +
+ + + dblclick event + Trigger the "dblclick" event on an element. + + 1.0 + + The string "dblclick". + + + +

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

+
+ +
+ +
diff --git a/entries/deferred.always.xml b/entries/deferred.always.xml index 57b3cf7f..30e92193 100644 --- a/entries/deferred.always.xml +++ b/entries/deferred.always.xml @@ -17,6 +17,7 @@ Add handlers to be called when the Deferred object is either resolved or rejected.

The argument can be either a single function or an array of functions. When the Deferred is resolved or rejected, the alwaysCallbacks are called. Since deferred.always() returns the Deferred object, other methods of the Deferred object can be chained to this one, including additional .always() methods. When the Deferred is resolved or rejected, callbacks are executed in the order they were added, using the arguments provided to the resolve, reject, resolveWith or rejectWith method calls. For more information, see the documentation for Deferred object.

+

Note: The deferred.always() method receives the arguments that were used to .resolve() or .reject() the Deferred object, which are often very different. For this reason, it's best to use it only for actions that do not require inspecting the arguments. In all other cases, use explicit .done() or .fail() handlers since the arguments will have well-known orders.

Since the jQuery.get() method returns a jqXHR object, which is derived from a Deferred object, we can attach a callback for both success and error using the deferred.always() method. diff --git a/entries/deferred.catch.xml b/entries/deferred.catch.xml new file mode 100644 index 00000000..e6e3d95a --- /dev/null +++ b/entries/deferred.catch.xml @@ -0,0 +1,31 @@ + + + deferred.catch() + + 3.0 + + + A function that is called when the Deferred is rejected. + + + + Add handlers to be called when the Deferred object is rejected. + + +

deferred.catch( fn ) is an alias to deferred.then( null, fn ). Read its page for more information.

+
+ + Since the jQuery.get method returns a jqXHR object, which is derived from a Deferred object, we can add rejection handlers using the .catch method. + + + + +
diff --git a/entries/deferred.isRejected.xml b/entries/deferred.isRejected.xml index 5fdd1e95..a391f779 100644 --- a/entries/deferred.isRejected.xml +++ b/entries/deferred.isRejected.xml @@ -6,8 +6,10 @@ Determine whether a Deferred object has been rejected. -

As of jQuery 1.7 this API has been deprecated; please use deferred.state() instead.

-

Returns true if the Deferred object is in the rejected state, meaning that either deferred.reject() or deferred.rejectWith() has been called for the object and the failCallbacks have been called (or are in the process of being called).

+
+

Note: This API has been removed in jQuery 1.8; please use deferred.state() instead.

+
+

Returns true if the Deferred object is in the rejected state, meaning that either deferred.reject() or deferred.rejectWith() has been called for the object and the failCallbacks have been called (or are in the process of being called).

Note that a Deferred object can be in one of three states: pending, resolved, or rejected; use deferred.isResolved() to determine whether the Deferred object is in the resolved state. These methods are primarily useful for debugging, for example to determine whether a Deferred has already been resolved even though you are inside code that intended to reject it.

diff --git a/entries/deferred.isResolved.xml b/entries/deferred.isResolved.xml index b5941322..9c046e5a 100644 --- a/entries/deferred.isResolved.xml +++ b/entries/deferred.isResolved.xml @@ -6,7 +6,9 @@ Determine whether a Deferred object has been resolved. -

This API is deprecated as of jQuery 1.7 and removed as of jQuery 1.8; please use deferred.state() instead.

+
+

Note: This API has been removed in jQuery 1.8; please use deferred.state() instead.

+

Returns true if the Deferred object is in the resolved state, meaning that either deferred.resolve() or deferred.resolveWith() has been called for the object and the doneCallbacks have been called (or are in the process of being called).

Note that a Deferred object can be in one of three states: pending, resolved, or rejected; use deferred.isRejected() to determine whether the Deferred object is in the rejected state. These methods are primarily useful for debugging, for example to determine whether a Deferred has already been resolved even though you are inside code that intended to reject it.

diff --git a/entries/deferred.pipe.xml b/entries/deferred.pipe.xml index 66eda149..a74f9dac 100644 --- a/entries/deferred.pipe.xml +++ b/entries/deferred.pipe.xml @@ -34,7 +34,9 @@ Utility method to filter and/or chain Deferreds. -

Deprecation Notice:As of jQuery 1.8, the deferred.pipe() method is deprecated. The deferred.then() method, which replaces it, should be used instead.

+
+

Deprecation Notice:As of jQuery 1.8, the deferred.pipe() method is deprecated. The deferred.then() method, which replaces it, should be used instead.

+

The deferred.pipe() method returns a new promise that filters the status and values of a deferred through a function. The doneFilter and failFilter functions filter the original deferred's resolved / rejected status and values. As of jQuery 1.7, the method also accepts a progressFilter function to filter any calls to the original deferred's notify or notifyWith methods. These filter functions can return a new value to be passed along to the piped promise's done() or fail() callbacks, or they can return another observable object (Deferred, Promise, etc) which will pass its resolved / rejected status and values to the piped promise's callbacks. If the filter function used is null, or not specified, the piped promise will be resolved or rejected with the same values as the original.

diff --git a/entries/deferred.progress.xml b/entries/deferred.progress.xml index d1f18cc7..87189af9 100644 --- a/entries/deferred.progress.xml +++ b/entries/deferred.progress.xml @@ -14,7 +14,7 @@ - Optional additional function, or array of functions, to be called when the Deferred generates progress notifications. + Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications. diff --git a/entries/deferred.promise.xml b/entries/deferred.promise.xml index d2a4c12d..db6550bd 100644 --- a/entries/deferred.promise.xml +++ b/entries/deferred.promise.xml @@ -9,7 +9,7 @@ Return a Deferred's Promise object. -

The deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request. The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state (then, done, fail, always, pipe, progress, and state), but not ones that change the state (resolve, reject, notify, resolveWith, rejectWith, and notifyWith).

+

The deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request. The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state (then, done, fail, always, pipe, progress, state and promise), but not ones that change the state (resolve, reject, notify, resolveWith, rejectWith, and notifyWith).

If target is provided, deferred.promise() will attach the methods onto it and then return this object rather than create a new one. This can be useful to attach the Promise behavior to an object that already exists.

If you are creating a Deferred, keep a reference to the Deferred so that it can be resolved or rejected at some point. Return only the Promise object via deferred.promise() so other code can register callbacks or inspect the current state.

For more information, see the documentation for Deferred object.

diff --git a/entries/delay.xml b/entries/delay.xml index c94b2a0b..b2066217 100644 --- a/entries/delay.xml +++ b/entries/delay.xml @@ -21,7 +21,7 @@ $( "#foo" ).slideUp( 300 ).delay( 800 ).fadeIn( 400 );

When this statement is executed, the element slides up for 300 milliseconds and then pauses for 800 milliseconds before fading in for 400 milliseconds.

- The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases. + The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

@@ -44,7 +44,7 @@ $( "#foo" ).slideUp( 300 ).delay( 800 ).fadeIn( 400 ); } ]]>
- + .delegate() Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. @@ -41,7 +41,7 @@ -

As of jQuery 1.7, .delegate() has been superseded by the .on() method. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:

+

As of jQuery 3.0, .delegate() has been deprecated. It was superseded by the .on() method since jQuery 1.7, so its use was already discouraged. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:


 // jQuery 1.4.3+
 $( elements ).delegate( selector, events, data, handler );
@@ -127,7 +127,7 @@ $( "body" ).delegate( "p", "myCustomEvent", function( e, myName, myValue ) {
     .fadeIn( 30 )
     .fadeOut( 1000 );
 });
-$( "button" ).click(function() {
+$( "button" ).on( "click", function() {
   $( "p" ).trigger( "myCustomEvent" );
 });
 ]]>
@@ -148,4 +148,5 @@ $( "button" ).click(function() {
   
   
   
+  
 
diff --git a/entries/dequeue.xml b/entries/dequeue.xml
index 7caca4e3..c54401c7 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.
     
     Detach all paragraphs from the DOM
     
   
   
+    
+

Note: This API has been removed in jQuery 1.9; please use on() instead.

+

Any handler that has been attached with .live() can be removed with .die(). This method is analogous to calling .off() with no arguments, which is used to remove all handlers attached with .on(). See the discussions of .live() and .off() for further details.

If used without an argument, .die() removes all event handlers previously attached using .live() from the elements.

diff --git a/entries/disabled-selector.xml b/entries/disabled-selector.xml index f018318c..812c8f57 100644 --- a/entries/disabled-selector.xml +++ b/entries/disabled-selector.xml @@ -9,9 +9,9 @@

As with other pseudo-class selectors (those that begin with a ":"), it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare $(':disabled') is equivalent to $('*:disabled'), so $('input:disabled') or similar should be used instead.

-

Although their resulting selections are usually the same, the :disabled selector is subtly different from the [disabled] attribute selector; :disabled checks the boolean (true/false) value of the element's disabled property while [disabled] checks for the existence of the disabled attribute.

+

Although their resulting selections are usually the same, the :disabled selector is subtly different from the [disabled] attribute selector;:disabled matches elements that are actually disabled while [disabled] only checks for the existence of the disabled attribute.

-

The :disabled selector should only be used for selecting HTML elements that support the disabled attribute (<button>, <input>, <optgroup>, <option>, <select>, and <textarea>).

+

The :disabled selector should only be used for selecting HTML elements that support the disabled attribute (<button>, <input>, <optgroup>, <option>, <select>, <textarea>, <menuitem>, and <fieldset>).

diff --git a/entries/each.xml b/entries/each.xml index 9a882fb2..fd2db648 100644 --- a/entries/each.xml +++ b/entries/each.xml @@ -6,7 +6,7 @@ A function to execute for each matched element. - + Iterate over a jQuery object, executing a function for each matched element. @@ -46,15 +46,15 @@ $( "li" ).addClass( "bar" ); Iterate over three divs and sets their color property. To access a jQuery object instead of the regular DOM element, use $( this ). For example: (click here to change) Use return false to break out of each() loops early.

This is the inverse of :parent.

One important thing to note with :empty (and :parent) is that child elements include text nodes.

-

The W3C recommends that the <p> element have at least one child node, even if that child is merely text (see http://www.w3.org/TR/html401/struct/text.html#edef-P). Some other elements, on the other hand, are empty (i.e. have no children) by definition: <input>, <img>, <br>, and <hr>, for example.

+

The W3C recommends that the <p> element have at least one child node, even if that child is merely text (see https://www.w3.org/TR/html401/struct/text.html#edef-P). Some other elements, on the other hand, are empty (i.e. have no children) by definition: <input>, <img>, <br>, and <hr>, for example.

Finds all elements that are empty - they don't have child elements or text. diff --git a/entries/empty.xml b/entries/empty.xml index 2be809f4..097ad9c6 100644 --- a/entries/empty.xml +++ b/entries/empty.xml @@ -31,9 +31,9 @@ $( ".hello" ).empty(); Removes all child nodes (including text nodes) from all paragraphs - + :eq() Selector :eq(index) @@ -17,6 +17,9 @@ Select the element at index n within the matched set. +
+

As of jQuery 3.4, the :eq pseudo-class is deprecated. Remove it from your selectors and filter the results later using .eq().

+

The index-related selectors (:eq(), :lt(), :gt(), :even, :odd) filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set. For example, if elements are first selected with a class selector (.myclass) and four elements are returned, these elements are given indices 0 through 3 for the purposes of these selectors.

Note that since JavaScript arrays use 0-based indexing, these selectors reflect that fact. This is why $( ".myclass:eq(1)" ) selects the second element in the document with the class myclass, rather than the first. In contrast, :nth-child(n) uses 1-based indexing to conform to the CSS specification.

Prior to jQuery 1.8, the :eq(index) selector did not accept a negative value for index (though the .eq(index) method did).

@@ -92,4 +95,5 @@ $( "li:eq(-2)" ).addClass( "foo" ) +
diff --git a/entries/error-shorthand.xml b/entries/error-shorthand.xml new file mode 100644 index 00000000..b40d9b75 --- /dev/null +++ b/entries/error-shorthand.xml @@ -0,0 +1,37 @@ + + + .error() + Bind an event handler to the "error" 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 .error( handler ) or .error( eventData, handler ), use .on( "error", handler ) or .on( "error", eventData, handler ), respectively.

+

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

+
+
+ + + + + +
diff --git a/entries/error.xml b/entries/error.xml index ff4a0ccf..d1f9493e 100644 --- a/entries/error.xml +++ b/entries/error.xml @@ -1,16 +1,15 @@ - - .error() - Bind an event handler to the "error" JavaScript event. + +Bind an event handler to the "error" event, or trigger that event on an element. + + + error event + Bind an event handler to the "error" event. - 1.0 - - A function to execute when the event is triggered. - + 1.7 + + The string "error". - - - 1.4.3 An object containing data that will be passed to the event handler. @@ -20,7 +19,9 @@ -

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

+
+

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

+

The error event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly.

For example, consider a page with a simple image element:


@@ -29,32 +30,50 @@
     

The event handler can be bound to the image:


 $( "#book" )
-  .error(function() {
-    alert( "Handler for .error() called." )
-  })
+  .on( "error", function() {
+    alert( "Handler for `error` called." )
+  } )
   .attr( "src", "missing.png" );
     
-

If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed:

+

If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed:

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

-

The event handler must be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler. Also, the error event may not be correctly fired when the page is served locally; error relies on HTTP status codes and will generally not be triggered if the URL uses the file: protocol.

+

The event handler must be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler. Also, the error event may not be correctly fired when the page is served locally; error relies on HTTP status codes and will generally not be triggered if the URL uses the file: protocol.

-

Note: A jQuery error event handler should not be attached to the window object. The browser fires the window's error event when a script error occurs. However, the window error event receives different arguments and has different return value requirements than conventional event handlers. Use window.onerror instead.

+

Note: A jQuery error event handler should not be attached to the window object. The browser fires the window's error event when a script error occurs. However, the window error event receives different arguments and has different return value requirements than conventional event handlers. Use window.onerror instead.

- To hide the "broken image" icons for IE users, you can try: + To replace all the missing images with another, you can update the src attribute inside the error handler. Be sure that the replacement image exists; otherwise the error event will be triggered indefinitely. - - + + + + + error event + Trigger the "error" event on an element. + + 1.0 + + The string "error". + + + +

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

+
+ +
+ + diff --git a/entries/even-selector.xml b/entries/even-selector.xml index f190e066..bfc8038a 100644 --- a/entries/even-selector.xml +++ b/entries/even-selector.xml @@ -1,12 +1,15 @@ - + :even Selector :even 1.0 - Selects even elements, zero-indexed. See also odd. + Selects even elements, zero-indexed. See also :odd. +
+

As of jQuery 3.4, the :even pseudo-class is deprecated. Remove it from your selectors and filter the results later using .even() (available in jQuery 3.5.0 or newer).

+

In particular, note that the 0-based indexing means that, counter-intuitively, :even selects the first element, third element, and so on within the matched set.

@@ -33,4 +36,5 @@ $( "tr:even" ).css( "background-color", "#bbf" ); +
diff --git a/entries/even.xml b/entries/even.xml new file mode 100644 index 00000000..cecff9e4 --- /dev/null +++ b/entries/even.xml @@ -0,0 +1,47 @@ + + + .even() + + 3.5 + + Reduce the set of matched elements to the even ones in the set, numbered from zero. + +

Given a jQuery object that represents a set of DOM elements, the .even() method constructs a new jQuery object from the even elements in that set. Counting starts from zero!

+

Consider a page with a simple list on it:

+

+<ul>
+  <li>list item 1</li>
+  <li>list item 2</li>
+  <li>list item 3</li>
+  <li>list item 4</li>
+  <li>list item 5</li>
+</ul>
+    
+

We can apply this method to the set of list items:

+

+$( "li" ).even().css( "background-color", "red" );
+    
+

The result of this call is a red background for the first, third & 5th items.

+
+ + Highlight the even items in a list. + + + +
  • Look:
  • +
  • This is some text in a list.
  • +
  • This is a note about it.
  • +
  • This is another note about it.
  • + +]]> +
    + + +
    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. Returns whether event.stopImmediatePropagation() was ever called on this event object. -

    This property was introduced in DOM level 3.

    +

    This property was introduced in DOM level 3.

    Checks whether event.stopImmediatePropagation() was called. @@ -21,7 +21,7 @@ function immediatePropStopped( event ) { $( "#stop-log" ).append( "
    " + msg + "
    " ); } -$( "button" ).click(function( event ) { +$( "button" ).on( "click", function( event ) { immediatePropStopped( event ); event.stopImmediatePropagation(); immediatePropStopped( event ); diff --git a/entries/event.isPropagationStopped.xml b/entries/event.isPropagationStopped.xml index ff7f7451..c6c270b4 100644 --- a/entries/event.isPropagationStopped.xml +++ b/entries/event.isPropagationStopped.xml @@ -6,7 +6,7 @@ Returns whether event.stopPropagation() was ever called on this event object. -

    This event method is described in the W3C DOM Level 3 specification.

    +

    This event method is described in the W3C DOM Level 3 specification.

    Checks whether event.stopPropagation() was called @@ -21,11 +21,11 @@ function propStopped( event ) { $( "#stop-log" ).append( "
    " + msg + "
    " ); } -$( "button" ).click(function(event) { +$( "button" ).on( "click", function( event ) { propStopped( event ); event.stopPropagation(); propStopped( event ); -}); +} ); ]]>
    click me diff --git a/entries/event.metaKey.xml b/entries/event.metaKey.xml index bca1b7b2..0c00d6b9 100644 --- a/entries/event.metaKey.xml +++ b/entries/event.metaKey.xml @@ -8,6 +8,8 @@

    Returns a boolean value (true or false) that indicates whether or not the META key was pressed at the time the event fired. This key might map to an alternative key name on some platforms.

    +

    On Macintosh keyboards, the META key maps to the Command key (⌘).

    +

    On Windows keyboards, the META key maps to the Windows key.

    Determine whether the META key was pressed when the event fired. @@ -24,7 +26,7 @@
    ]]> 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 68f0a43a..82b4e104 100644 --- a/entries/event.preventDefault.xml +++ b/entries/event.preventDefault.xml @@ -11,7 +11,7 @@ Cancel the default action (navigation) of the click. " ) .append( "default " + event.type + " prevented" ) @@ -19,7 +19,7 @@ $( "a" ).click(function( event ) { }); ]]> default click action is prevented +default click action is prevented
    ]]>
    diff --git a/entries/event.relatedTarget.xml b/entries/event.relatedTarget.xml index 97908df7..e4ee9eaf 100644 --- a/entries/event.relatedTarget.xml +++ b/entries/event.relatedTarget.xml @@ -11,9 +11,9 @@ On mouseout of anchors, alert the element type being entered. 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 b067e43a..dd86bd7c 100644 --- a/entries/event.stopImmediatePropagation.xml +++ b/entries/event.stopImmediatePropagation.xml @@ -1,5 +1,5 @@ - + event.stopImmediatePropagation() 1.3 @@ -25,14 +25,14 @@ } ]]> - + event.stopPropagation() 1.0 @@ -7,14 +7,14 @@ Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

    We can use event.isPropagationStopped() to determine if this method was ever called (on that event object).

    -

    This method works for custom events triggered with trigger(), as well.

    +

    This method works for custom events triggered with trigger() as well.

    Note that this will not prevent other handlers on the same element from running.

    Kill the bubbling on the click event. Display the tag's name on click @@ -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/event.timeStamp.xml b/entries/event.timeStamp.xml index f63b62ce..089997ba 100644 --- a/entries/event.timeStamp.xml +++ b/entries/event.timeStamp.xml @@ -22,7 +22,7 @@ ]]> " ); diff --git a/entries/event.type.xml b/entries/event.type.xml index 8bde7559..a51cc1c8 100644 --- a/entries/event.type.xml +++ b/entries/event.type.xml @@ -9,7 +9,7 @@ On all anchor clicks, alert the event type. diff --git a/entries/event.which.xml b/entries/event.which.xml index efa9cddf..e8e6aa28 100644 --- a/entries/event.which.xml +++ b/entries/event.which.xml @@ -6,7 +6,7 @@
    For key or mouse events, this property indicates the specific key or button that was pressed. -

    The event.which property normalizes event.keyCode and event.charCode. It is recommended to watch event.which for keyboard key input. For more detail, read about event.charCode on the MDC.

    +

    The event.which property normalizes event.keyCode and event.charCode. It is recommended to watch event.which for keyboard key input. For more detail, read about event.charCode on the MDN.

    event.which also normalizes button presses (mousedown and mouseupevents), reporting 1 for left button, 2 for middle, and 3 for right. Use event.which instead of event.button.

    diff --git a/entries/fadeIn.xml b/entries/fadeIn.xml index 819e663e..1975c039 100644 --- a/entries/fadeIn.xml +++ b/entries/fadeIn.xml @@ -29,20 +29,21 @@ <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 }); });
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the fadeIn() effect
    +

    Easing

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -51,9 +52,9 @@ $( "#clickme" ).click(function() { Animates hidden divs to fade in one by one, completing each animation within 600 milliseconds. Fades a red block in over the text. Once the animation is done, it quickly fades in more text on top.

    With the element initially shown, we can hide it slowly:

    
    -$( "#clickme" ).click(function() {
    +$( "#clickme" ).on( "click", function() {
       $( "#book" ).fadeOut( "slow", function() {
         // Animation complete.
       });
     });
         
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the fadeOut() effect
    +

    Note: To avoid unnecessary DOM manipulation, .fadeOut() will not hide an element that is already considered hidden. For information on which elements jQuery considers hidden, see :hidden Selector.

    Easing

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -55,7 +56,7 @@ $( "#clickme" ).click(function() { Animates all paragraphs to fade out, completing the animation within 600 milliseconds. @@ -75,7 +76,7 @@ $( "p" ).click(function() { Fades out spans in one section that you click on. Fades out two divs, one with a "linear" easing and one with the default, "swing," easing. " ).text( this.id ).appendTo( "#log" ); } @@ -120,7 +121,7 @@ $( "#btn1" ).click(function() { $( "#box2" ).fadeOut( 1600, complete ); }); -$( "#btn2" ).click(function() { +$( "#btn2" ).on( "click", function() { $( "div" ).show(); $( "#log" ).empty(); }); diff --git a/entries/fadeTo.xml b/entries/fadeTo.xml index 5ce98458..c77da0d6 100644 --- a/entries/fadeTo.xml +++ b/entries/fadeTo.xml @@ -44,27 +44,28 @@ </div> <img id="book" src="book.png" alt="" width="100" height="123"> // With the element initially shown, we can dim it slowly: -$( "#clickme" ).click(function() { +$( "#clickme" ).on( "click", function() { $( "#book" ).fadeTo( "slow" , 0.5, function() { // Animation complete. }); }); -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the fadeTo() effect
    +

    With duration set to 0, this method just changes the opacity CSS property, so .fadeTo( 0, opacity ) is the same as .css( "opacity", opacity ).

    Animates first paragraph to fade to an opacity of 0.33 (33%, about one third visible), completing the animation within 600 milliseconds. @@ -79,7 +80,7 @@ Compare to this one that won't fade. Fade div to a random opacity on each click, completing the animation within 200 milliseconds. @@ -127,26 +128,26 @@ var getPos = function( n ) { $( "p" ).each(function( n ) { var r = Math.floor( Math.random() * 3 ); var tmp = $( this ).text(); - $( this ).text( $( "p:eq(" + r + ")" ).text() ); - $( "p:eq(" + r + ")" ).text( tmp ); + $( 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" - }); - }); - }); + } ); + } ); + } ); ]]> The .fadeToggle() method animates the opacity of the matched elements. When called on a visible element, the element's display style property is set to none once the opacity reaches 0, so the element no longer affects the layout of the page.

    Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    Easing

    -

    The string representing an easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    The string representing an easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -26,14 +26,14 @@ Fades first paragraph in or out, completing the animation within 600 milliseconds and using a linear easing. Fades last paragraph in or out for 200 milliseconds, inserting a "finished" message upon completion. finished" ); - }); -}); + } ); +} ); ]]> fadeToggle p1 diff --git a/entries/file-selector.xml b/entries/file-selector.xml index db9c7b86..c5295eca 100644 --- a/entries/file-selector.xml +++ b/entries/file-selector.xml @@ -13,16 +13,16 @@ Finds all file inputs.

    We can apply this method to the set of list items:

    
    -$( "li" ).filter( ":even" ).css( "background-color", "red" );
    +$( "li" ).filter( ":nth-child(2n)" ).css( "background-color", "red" );
         
    -

    The result of this call is a red background for items 1, 3, and 5, as they match the selector (recall that :even and :odd use 0-based indexing).

    +

    The result of this call is a red background for items 2, 4, and 6, as they match the selector.

    Using a Filter Function

    The second form of this method allows us to filter elements against a function rather than a selector. For each element, if the function returns true (or a "truthy" value), the element will be included in the filtered set; otherwise, it will be excluded. Suppose we have a somewhat more involved HTML snippet:

    
    @@ -76,6 +76,8 @@ $( "li" )
         .css( "background-color", "red" );
         

    This alteration to the code will cause the third and sixth list items to be highlighted, as it uses the modulus operator (%) to select every item with an index value that, when divided by 3, has a remainder of 2.

    +

    Note: When a CSS selector string is passed to .filter(), text and comment nodes will always be removed from the resulting jQuery object during the filtering process. When a specific node or array of nodes are provided, a text or comment node will be included in the resulting jQuery object only if it matches one of the nodes in the filtering array.

    + Change the color of all divs; then add a border to those with a "middle" class. diff --git a/entries/find.xml b/entries/find.xml index b6a82654..fc10241b 100644 --- a/entries/find.xml +++ b/entries/find.xml @@ -18,7 +18,7 @@ Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

    Given a jQuery object that represents a set of DOM elements, the .find() method allows us to search through the descendants of these elements in the DOM tree and construct a new jQuery object from the matching elements. The .find() and .children() methods are similar, except that the latter only travels a single level down the DOM tree.

    -

    The first signature for the .find()method accepts a selector expression of the same type that we can pass to the $() function. The elements will be filtered by testing whether they match this selector.

    +

    The first signature for the .find()method accepts a selector expression of the same type that we can pass to the $() function. The elements will be filtered by testing whether they match this selector; all parts of the selector must lie inside of an element on which .find() is called. The expressions allowed include selectors like > p which will find all the paragraphs that are children of the elements in the jQuery object.

    Consider a page with a basic nested list on it:

    
     <ul class="level-1">
    @@ -63,6 +63,7 @@ var item1 = $( "li.item-1" )[ 0 ];
     $( "li.item-ii" ).find( item1 ).css( "background-color", "red" );
         

    The result of this call would be a red background on item 1.

    +
    Starts with all paragraphs and searches for descendant span elements, same as $( "p span" ) diff --git a/entries/first-child-selector.xml b/entries/first-child-selector.xml index 4b30b503..d91a50b8 100644 --- a/entries/first-child-selector.xml +++ b/entries/first-child-selector.xml @@ -7,7 +7,7 @@ Selects all elements that are the first child of their parent. -

    While :first matches only a single element, the :first-child selector can match more than one: one for each parent. This is equivalent to :nth-child(1).

    +

    While .first() matches only a single element, the :first-child selector can match more than one: one for each parent. This is equivalent to :nth-child(1).

    Finds the first span in each matched div to underline and add a hover state. diff --git a/entries/first-selector.xml b/entries/first-selector.xml index a0371809..1308ff5e 100644 --- a/entries/first-selector.xml +++ b/entries/first-selector.xml @@ -1,12 +1,15 @@ - + :first Selector :first 1.0 - Selects the first matched element. + Selects the first matched DOM element. +
    +

    As of jQuery 3.4, the :first pseudo-class is deprecated. Remove it from your selectors and filter the results later using .first().

    +

    The :first pseudo-class is equivalent to :eq( 0 ). It could also be written as :lt( 1 ). While this matches only a single element, :first-child can match more than one: One for each parent.

    @@ -33,4 +36,5 @@ $( "tr:first" ).css( "font-style", "italic" ); +
    diff --git a/entries/first.xml b/entries/first.xml index f73f8f10..90ac489c 100644 --- a/entries/first.xml +++ b/entries/first.xml @@ -24,21 +24,22 @@ $( "li" ).first().css( "background-color", "red" );

    The result of this call is a red background for the first item.

    - Highlight the first span in a paragraph. + Highlight the first item in a list. - Look: - This is some text in a paragraph. - This is a note about it. -

    +
      +
    • Look:
    • +
    • This is some text in a list.
    • +
    • This is a note about it.
    • +
    • This is another note about it.
    • +
    ]]>
    diff --git a/entries/focus-shorthand.xml b/entries/focus-shorthand.xml new file mode 100644 index 00000000..a38f4c28 --- /dev/null +++ b/entries/focus-shorthand.xml @@ -0,0 +1,37 @@ + + + .focus() + Bind an event handler to the "focus" 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 .focus( handler ) or .focus( eventData, handler ), use .on( "focus", handler ) or .on( "focus", eventData, handler ), respectively.

    +

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

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

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

    +
      -
    • This method is a shortcut for .on( "focus", handler ) in the first and second variations, and .trigger( "focus" ) in the third.
    • The focus event is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property. An element can gain focus via keyboard commands, such as the Tab key, or by mouse clicks on the element.
    • Elements with focus are usually highlighted in some way by the browser, for example with a dotted line surrounding the element. The focus is used to determine which element is the first to receive keyboard-related events.
    -

    Attempting to set focus to a hidden element causes an error in Internet Explorer. Take care to only use .focus() on elements that are visible. To run an element's focus event handlers without setting focus to the element, use .triggerHandler( "focus" ) instead of .focus().

    +

    Attempting to set focus to a hidden element causes an error in Internet Explorer. Take care to only use .trigger( "focus" ) on elements that are visible. To run an element's focus event handlers without setting focus to the element, use .triggerHandler( "focus" ) instead of .trigger( "focus" ).

    For example, consider the HTML:

    
    @@ -43,22 +41,23 @@
         

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

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

    Now clicking on the first field, or tabbing to it from another field, displays the alert:

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

    We can trigger the event when another element is clicked:

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

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

    -

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

    +

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

    +

    The native focus event is asynchronous in all versions of IE, contrary to other browsers. To avoid issues related to this discrepancy, as of jQuery 3.7.0, jQuery uses focusin as the native backing event for focus in IE.

    Fire focus. @@ -68,9 +67,9 @@ $( "#other" ).click(function() { } ]]>
    focus fire

    @@ -80,21 +79,41 @@ $( "input" ).focus(function() { To stop people from writing in text input boxes, try: 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 dd273e67..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. @@ -20,7 +19,9 @@ -

    This method is a shortcut for .on('focusin', handler).

    +
    +

    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.

    @@ -32,9 +33,9 @@ } ]]> focusin fire

    @@ -42,6 +43,28 @@ $( "p" ).focusin(function() { ]]>
    + + + + + + + + focusin event + Trigger the "focusin" event on an element. + + 1.0 + + The string "focusin". + + + +

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

    +
    + + + -
    + + diff --git a/entries/focusout-shorthand.xml b/entries/focusout-shorthand.xml new file mode 100644 index 00000000..6114a08b --- /dev/null +++ b/entries/focusout-shorthand.xml @@ -0,0 +1,37 @@ + + + .focusout() + Bind an event handler to the "focusout" 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 .focusout( handler ) or .focusout( eventData, handler ), use .on( "focusout", handler ) or .on( "focusout", eventData, handler ), respectively.

    +

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

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

    This method is a shortcut for .on( "focusout", handler ) when passed arguments, and .trigger( "focusout" ) when no arguments are passed.

    +
    +

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

    +

    The focusout event is sent to an element when it, or any element inside of it, loses focus. This is distinct from the blur event in that it supports detecting the loss of focus on descendant elements (in other words, it supports event bubbling).

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

    @@ -36,17 +37,17 @@ } ]]> @@ -62,8 +63,29 @@ $( "p" )
    blur fire
    ]]>
    - - + + + + + + + + + focusout event + Trigger the "focuout" event on an element. + + 1.0 + + The string "focusout". + + + +

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

    +
    + + + -
    + + diff --git a/entries/get.xml b/entries/get.xml index 64272cf4..cb52eb2d 100644 --- a/entries/get.xml +++ b/entries/get.xml @@ -43,10 +43,10 @@ console.log( $( "li" ).get( -1 ) ); Display the tag name of the click element. - + :gt() Selector :gt(index) @@ -17,6 +17,9 @@ Select all elements at an index greater than index within the matched set. +
    +

    As of jQuery 3.4, the :gt pseudo-class is deprecated. Remove it from your selectors and filter the results later using .slice(). For example, :gt(3) can be replaced with a call to .slice( 4 ) (the provided index needs to be increased by one).

    +

    index-related selectors

    @@ -42,4 +45,5 @@ $( "td:gt(-2)" ).css( "color", "red" ); +
    diff --git a/entries/hasClass.xml b/entries/hasClass.xml index 37b52f79..622570e9 100644 --- a/entries/hasClass.xml +++ b/entries/hasClass.xml @@ -25,12 +25,13 @@ $( "#mydiv" ).hasClass( "bar" )
    
     $( "#mydiv" ).hasClass( "quux" )
         
    +

    As of jQuery 1.12/2.2, this method supports XML documents, including SVG.

    Looks for the paragraph that contains 'selected' as a class. Get the current computed height for the first element in the set of matched elements.

    The difference between .css( "height" ) and .height() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .height() method is recommended when an element's height needs to be used in a mathematical calculation.

    -

    +

    -

    +
    Figure 1 - Illustration of the measured height
    +

    This method is also able to find the height of the window and document.

    
     // Returns height of browser viewport
    @@ -26,20 +27,20 @@ $( document ).height();
           
         
         
    -    
    +    
         
           Show various heights.  Note the values are from the iframe so might be smaller than you expected.  The yellow highlight shows the iframe body.
           
    diff --git a/entries/hidden-selector.xml b/entries/hidden-selector.xml
    index 6712c736..44b8397c 100644
    --- a/entries/hidden-selector.xml
    +++ b/entries/hidden-selector.xml
    @@ -16,8 +16,10 @@
         
         

    Elements with visibility: hidden or opacity: 0 are considered to be visible, since they still consume space in the layout. During animations that hide an element, the element is considered to be visible until the end of the animation.

    Elements that are not in a document are not considered to be visible; jQuery does not have a way to know if they will be visible when appended to a document since it depends on the applicable styles.

    +

    This selector is the opposite of the :visible selector. So, every element selected by :hidden isn't selected by :visible and vice versa.

    During animations to show an element, the element is considered to be visible at the start of the animation.

    -

    How :hidden is determined was changed in jQuery 1.3.2. An element is assumed to be hidden if it or any of its parents consumes no space in the document. CSS visibility isn't taken into account (therefore $( elem ).css( "visibility", "hidden" ).is( ":hidden" ) == false). The release notes outline the changes in more detail.

    +

    How :hidden is determined was changed in jQuery 1.3.2. An element is assumed to be hidden if it or any of its parents consumes no space in the document. CSS visibility isn't taken into account (therefore $( elem ).css( "visibility", "hidden" ).is( ":hidden" ) == false). The release notes outline the changes in more detail.

    +

    jQuery 3 slightly modifies the meaning of :hidden (and therefore of :visible). Starting with this version, elements will be considered :hidden if they don't have any layout boxes. For example, br elements and inline elements with no content will not be selected by the :hidden selector.

    @@ -27,9 +29,9 @@ // In some browsers :hidden includes head, title, script, etc... var hiddenElements = $( "body" ).find( ":hidden" ).not( "script" ); -$( "span:first" ).text( "Found " + hiddenElements.length + " hidden elements total." ); +$( "span" ).first().text( "Found " + hiddenElements.length + " hidden elements total." ); $( "div:hidden" ).show( 3000 ); -$( "span:last" ).text( "Found " + $( "input:hidden" ).length + " hidden inputs." ); +$( "span" ).last().text( "Found " + $( "input:hidden" ).length + " hidden inputs." ); ]]>
    When a duration, a plain object, or a "complete" function is provided, .hide() becomes an animation method. The .hide() method animates the width, height, and opacity of the matched elements simultaneously. When these properties reach 0, the display style property is set to none to ensure that the element no longer affects the layout of the page.

    Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    Note that .hide() is fired immediately and will override the animation queue if no duration or a duration of 0 is specified.

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    +
    +

    Note: This method may cause performance issues, especially when used on many elements. If you're encountering such issues, use performance testing tools to determine whether this method is causing them. Moreover, this method can cause problems with responsive layouts if the display value differs at different viewport sizes.

    +

    We can animate any element, such as a simple image:

    
     <div id="clickme">
    @@ -46,25 +49,26 @@ $( ".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." );
       });
     });
         
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the hide() effect
    +
    Hides all paragraphs then the link on click. Animates all shown paragraphs to hide slowly, completing the animation within 600 milliseconds. @@ -97,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. @@ -130,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 3eb38753..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: @@ -30,7 +33,7 @@ $( "li" ).hover( function() { $( this ).append( $( " ***" ) ); }, function() { - $( this ).find( "span:last" ).remove(); + $( this ).find( "span" ).last().remove(); } ); @@ -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,21 +96,24 @@ $( "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. +
    diff --git a/entries/html.xml b/entries/html.xml index 7a4f2594..1a29d361 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.

    Given a document with six paragraphs, this example will set the HTML of <div class="demo-container"> to <p>All new content for <em>6 paragraphs!</em></p>.

    -

    This method uses the browser's innerHTML property. Some browsers may not generate a DOM that exactly replicates the HTML source provided. For example, Internet Explorer prior to version 8 will convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

    +

    This method uses the browser's innerHTML property. Some browsers may not generate a DOM that exactly replicates the HTML source provided. For example, Internet Explorer prior to version 8 will convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

    To set the content of a <script> element, which does not contain HTML, use the .text() method and not .html().

    Note: In Internet Explorer up to and including version 9, setting the text content of an HTML element may corrupt the text nodes of its children that are being removed from the document as a result of the operation. If you are keeping references to these DOM elements and need them to be unchanged, use .empty().html( string ) instead of .html(string) so that the elements are removed from the document before the new string is assigned to the element.

    diff --git a/entries/id-selector.xml b/entries/id-selector.xml index 20aab992..3cc8b926 100644 --- a/entries/id-selector.xml +++ b/entries/id-selector.xml @@ -13,7 +13,7 @@

    For id selectors, jQuery uses the JavaScript function document.getElementById(), which is extremely efficient. When another selector is attached to the id selector, such as h2#pageTitle, jQuery performs an additional check before identifying the element as a match.

    Calling jQuery() (or $()) with an id selector as its argument will return a jQuery object containing a collection of either zero or one DOM element.

    Each id value must be used only once within a document. If more than one element has been assigned the same ID, queries that use that ID will only select the first matched element in the DOM. This behavior should not be relied on, however; a document with more than one element using the same ID is invalid.

    -

    If the id contains characters like periods or colons you have to escape those characters with backslashes.

    +

    If the id contains characters like periods or colons you have to escape those characters with backslashes.

    Select the element with the id "myDiv" and give it a red border. diff --git a/entries/image-selector.xml b/entries/image-selector.xml index 8af0a351..2b569d3a 100644 --- a/entries/image-selector.xml +++ b/entries/image-selector.xml @@ -13,16 +13,16 @@ Finds all image inputs. - + .index() 1.4 @@ -53,7 +53,7 @@ alert( "Index: " + $( "li" ).index( listItem ) );

    Note that if the jQuery collection used as the .index() method's argument contains more than one element, the first element within the matched set of elements will be used.

    
    -var listItems = $( "li:gt(0)" );
    +var listItems = $( "li" ).slice( 1 );
     alert( "Index: " + $( "li" ).index( listItems ) );
         

    We get back the zero-based position of the first list item within the matched set:

    @@ -81,7 +81,7 @@ alert( "Index: " + $( "#bar" ).index() ); On click, returns the index (zero-based) of that div in the page.
    Get the current computed height for the first element in the set of matched elements, including padding but not border. -

    This method returns the height of the element, including top and bottom padding, in pixels.

    +

    This method returns the height of the element, including top and bottom padding, in pixels. If called on an empty set of elements, returns undefined (null before jQuery 3.0).

    This method is not applicable to window and document objects; for these, use .height() instead.

    -

    +

    -

    +
    Figure 1 - Illustration of the measured height
    +
    - - + + Get the innerHeight of a paragraph. - 1.8.0 + 1.8 @@ -51,7 +52,7 @@ $( "p:last" ).text( "innerHeight:" + p.innerHeight() ); - 1.8.0 + 1.8 diff --git a/entries/innerWidth.xml b/entries/innerWidth.xml index 3356884d..54b6b358 100644 --- a/entries/innerWidth.xml +++ b/entries/innerWidth.xml @@ -1,26 +1,27 @@ Get the current computed inner width (including padding but not border) for the first element in the set of matched elements or set the inner width of every matched element. - + .innerWidth() 1.2.6 Get the current computed inner width for the first element in the set of matched elements, including padding but not border. -

    This method returns the width of the element, including left and right padding, in pixels.

    +

    This method returns the width of the element, including left and right padding, in pixels. If called on an empty set of elements, returns undefined (null before jQuery 3.0).

    This method is not applicable to window and document objects; for these, use .width() instead.

    -

    +

    -

    +
    Figure 1 - Illustration of the measured width
    +
    - - + + Get the innerWidth of a paragraph. - 1.8.0 + 1.8 - - - A number representing the number of pixels, or a number along with an optional unit of measure appended (as a string). + + + A number representing the number of pixels, or a number along with an optional unit of measure appended (as a string). - 1.8.0 + 1.8 diff --git a/entries/input-selector.xml b/entries/input-selector.xml index 7f5d8fd9..ec5c6c23 100644 --- a/entries/input-selector.xml +++ b/entries/input-selector.xml @@ -18,9 +18,9 @@ var formChildren = $( "form > *" ); $( "#messages" ).text( "Found " + allInputs.length + " inputs and the form has " + formChildren.length + " children." ); -$( "form" ).submit(function( event ) { +$( "form" ).on( "submit", function( event ) { event.preventDefault(); -}); +} ); ]]>
    Insert every element in the set of matched elements after the target. -

    The .after() and .insertAfter() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target. With .after(), the selector expression preceding the method is the container after which the content is inserted. With .insertAfter(), on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted after the target container.

    +

    The .after() and .insertAfter() methods perform the same task. The major difference is in the syntax—specifically, in the placement of the content and target. With .after(), the selector expression preceding the method is the container after which the content is inserted. With .insertAfter(), on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted after the target container.

    Consider the following HTML:

    
     <div class="container">
    @@ -53,6 +53,7 @@ $( "h2" ).insertAfter( $( ".container" ) );
         

    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.

    + Insert all paragraphs after an element with id of "foo". Same as $( "#foo" ).after( "p" ) 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.

    + Insert all paragraphs before an element with id of "foo". Same as $( "#foo" ).before( "p" ) A function used as a test for every element in the set. It accepts two arguments, index, which is the element's index in the jQuery collection, and element, which is the DOM element. Within the function, this refers to the current DOM element. - + @@ -41,7 +41,7 @@

    You can attach a click handler to the <ul> element, and then limit the code to be triggered only when a list item itself, not one of its children, is clicked:

    
    -$( "ul" ).click(function( event ) {
    +$( "ul" ).on( "click", function( event ) {
       var target = $( event.target );
       if ( target.is( "li" ) ) {
         target.css( "background-color", "red" );
    @@ -49,8 +49,6 @@ $( "ul" ).click(function( event ) {
     });
         

    Now, when the user clicks on the word "list" in the first item or anywhere in the third item, the clicked list item will be given a red background. However, when the user clicks on item 1 in the first item or anywhere in the second item, nothing will occur, because in those cases the target of the event would be <strong> or <span>, respectively.

    -

    Prior to jQuery 1.7, in selector strings with positional selectors such as :first, :gt(), or :even, the positional filtering is done against the jQuery object passed to .is(), not against the containing document. So for the HTML shown above, an expression such as $( "li:first" ).is( "li:last" ) returns true, but $( "li:first-child" ).is( "li:last-child" ) returns false. In addition, a bug in Sizzle prevented many positional selectors from working properly. These two factors made positional selectors almost unusable in filters.

    -

    Starting with jQuery 1.7, selector strings with positional selectors apply the selector against the document, and then determine whether the first element of the current jQuery set matches any of the resulting elements. So for the HTML shown above, an expression such as $( "li:first" ).is( "li:last" ) returns false. Note that since positional selectors are jQuery additions and not W3C standard, we recommend using the W3C selectors whenever feasible.

    Using a Function

    The second form of this method evaluates expressions related to elements based on a function rather than a selector. For each element, if the function returns true, .is() returns true as well. For example, given a somewhat more involved HTML snippet:

    
    @@ -65,7 +63,7 @@ $( "ul" ).click(function( event ) {
         

    You can attach a click handler to every <li> that evaluates the number of <strong> elements within the clicked <li> at that time like so:

    
    -$( "li" ).click(function() {
    +$( "li" ).on( "click", function() {
       var li = $( this ),
         isWithTwo = li.is(function() {
           return $( "strong", this ).length === 2;
    @@ -179,7 +177,7 @@ $( "div" ).text( "isFormParent = " + isFormParent );
         Checks against an existing collection of alternating list elements. Blue, alternating list elements slide up while others turn red.
         An alternate way to achieve the above example using an element rather than a jQuery object. Checks against an existing collection of alternating list elements. Blue, alternating list elements slide up while others turn red.
         

    The result of this is that it becomes simple to construct complex lists of callbacks where input values can be passed through to as many functions as needed with ease.

    Two specific methods were being used above: .add() and .fire(). The .add() method supports adding new callbacks to the callback list, while the .fire() method executes the added functions and provides a way to pass arguments to be processed by the callbacks in the same list.

    -

    Another method supported by $.Callbacks is .remove(), which has the ability to remove a particular callback from the callback list. Here"s a practical example of .remove() being used:

    +

    Another method supported by $.Callbacks is .remove(), which has the ability to remove a particular callback from the callback list. Here's a practical example of .remove() being used:

    
     var callbacks = $.Callbacks();
     callbacks.add( fn1 );
    @@ -259,7 +259,7 @@ dfd.done( topic.publish );
     // Here the Deferred is being resolved with a message
     // that will be passed back to subscribers. It's possible to
     // easily integrate this into a more complex routine
    -// (eg. waiting on an ajax call to complete) so that
    +// (eg. waiting on an Ajax call to complete) so that
     // messages are only published once the task has actually
     // finished.
     dfd.resolve( "it's been published!" );
    diff --git a/entries/jQuery.ajax.xml b/entries/jQuery.ajax.xml
    index d7b49447..9074388b 100644
    --- a/entries/jQuery.ajax.xml
    +++ b/entries/jQuery.ajax.xml
    @@ -15,11 +15,31 @@
         1.0
         
           A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
    -      
    -        The content type sent in the request header that tells the server what kind of response it will accept in return.
    +      
    +        A set of key/value pairs that map a given dataType to its MIME type, which gets sent in the Accept request header. This header tells the server what kind of response it will accept in return. For example, the following defines a custom type mycustomtype to be sent with the request:
    +          
    
    +$.ajax({
    +  accepts: {
    +    mycustomtype: 'application/x-some-custom-type'
    +  },
    +
    +  // Instructions for how to deserialize a `mycustomtype`
    +  converters: {
    +    'text mycustomtype': function(result) {
    +      // Do Stuff
    +      return newresult;
    +    }
    +  },
    +
    +  // Expect a `mycustomtype` back from server
    +  dataType: 'mycustomtype'
    +});
    +          
    + Note: You will need to specify a complementary entry for this type in converters for this to work properly. +
    - By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success(). + By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done(). @@ -43,7 +63,7 @@ When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header. Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server. - This object will be the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). For example, specifying a DOM element as the context will make that the context for the complete callback of a request, like so: + This object will be the context of all Ajax-related callbacks. By default, the context is an object that represents the Ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). For example, specifying a DOM element as the context will make that the context for the complete callback of a request, like so:
    
     $.ajax({
       url: "test.html",
    @@ -64,7 +84,12 @@ $.ajax({
             
             
             
    -        Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
    +        
    +            

    Data to be sent to the server. If the HTTP method is one that cannot have an entity body, such as GET, the data is appended to the URL.

    +

    When data is an object, jQuery generates the data string from the object's key/value pairs unless the processData option is set to false. For example, { a: "bc", d: "e,f" } is converted to the string "a=bc&d=e%2Cf". If the value is an array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). For example, { a: [1,2] } becomes the string "a%5B%5D=1&a%5B%5D=2" with the default traditional: false setting.

    +

    When data is passed as a string it should already be encoded using the correct encoding for contentType, which by default is application/x-www-form-urlencoded.

    +

    In requests with dataType: "json" or dataType: "jsonp", if the string contains a double question mark (??) anywhere in the URL or a single question mark (?) in the query string, it is replaced with a value generated by jQuery that is unique for each copy of the library on the page (e.g. jQuery21406515378922229067_1479880736745).

    +
    @@ -74,15 +99,22 @@ $.ajax({ The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are: -
    • "xml": Returns a XML document that can be processed via jQuery.
    • "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
    • "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests.
    • "json": Evaluates the response as JSON and returns a JavaScript object. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead. (See json.org for more information on proper JSON formatting.)
    • "jsonp": Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true.
    • "text": A plain text string.
    • multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml." Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml. -
    +
      +
    • "xml": Returns a XML document that can be processed via jQuery.
    • +
    • "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
    • +
    • "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, _=[TIMESTAMP], to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests. Prior to jQuery 3.5.0, unsuccessful HTTP responses with a script Content-Type were still executed.
    • +
    • "json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain "json" requests that have a callback placeholder, e.g. ?callback=?, are performed using JSONP unless the request includes jsonp: false in its request options. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead. (See json.org for more information on proper JSON formatting.)
    • +
    • "jsonp": Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true.
    • +
    • "text": A plain text string.
    • +
    • multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml". Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml.
    • +
    - A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. + A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." (in HTTP/2 it may instead be an empty string) As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain scripts and cross-domain JSONP requests. This is an Ajax Event. Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. @@ -96,15 +128,17 @@ $.ajax({ Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. - - Override the callback function name in a JSONP request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" } + + + + Override the callback function name in a JSONP request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" }. If you don't trust the target of your Ajax requests, consider setting the jsonp property to false for security reasons. Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. - + The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). @@ -114,10 +148,13 @@ $.ajax({ A password to be used with XMLHttpRequest in response to an HTTP access authentication request. - By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. + By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. + + + Defines an object with additional attributes to be used in a "script" or "jsonp" request. The key represents the name of the attribute and the value is the attribute's value. If this object is provided it will force the use of a script-tag transport. For example, this can be used to set nonce, integrity, or crossorigin attributes to satisfy Content Security Policy requirements. - Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. + Only applies when the "script" transport is used. Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. Alternatively, the charset attribute can be specified in scriptAttrs instead, which will also ensure the use of the "script" transport. @@ -141,7 +178,7 @@ $.ajax({ A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. - Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. + Set a timeout (in milliseconds) for the request. A value of 0 means there will be no timeout. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. Set this to true if you wish to use the traditional style of param serialization. @@ -188,7 +225,7 @@ $.ajax();

    As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header:

    
     $.ajax({
    -  url: "http://fiddle.jshell.net/favicon.png",
    +  url: "https://fiddle.jshell.net/favicon.png",
       beforeSend: function( xhr ) {
         xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
       }
    @@ -203,7 +240,7 @@ $.ajax({
         
    • jqXHR.done(function( data, textStatus, jqXHR ) {}); -

      An alternative construct to the success callback option, the .done() method replaces the deprecated jqXHR.success() method. Refer to deferred.done() for implementation details.

      +

      An alternative construct to the success callback option, refer to deferred.done() for implementation details.

    • jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {}); @@ -211,7 +248,7 @@ $.ajax({

    • - jqXHR.always(function( data|jqXHR, textStatus, jqXHR|errorThrown ) { }); + jqXHR.always(function( data|jqXHR, textStatus, jqXHR|errorThrown ) { }); (added in jQuery 1.6)

      An alternative construct to the complete callback option, the .always() method replaces the deprecated .complete() method.

      In response to a successful request, the function's arguments are the same as those of .done(): data, textStatus, and the jqXHR object. For failed requests the arguments are the same as those of .fail(): the jqXHR object, textStatus, and errorThrown. Refer to deferred.always() for implementation details.

    • @@ -222,7 +259,7 @@ $.ajax({
    -

    Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    +

    Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    
     // Assign handlers immediately after making the request,
    @@ -251,25 +288,32 @@ jqxhr.always(function() {
           
  • readyState
  • +
  • + responseXML and/or responseText when the underlying request responded with xml and/or text, respectively +
  • status
  • - statusText + statusText (may be an empty string in HTTP/2) +
  • +
  • + abort( [ statusText ] ) +
  • +
  • + getAllResponseHeaders() as a string
  • -
  • responseXML and/or responseText when the underlying request responded with xml and/or text, respectively
  • -
  • setRequestHeader(name, value) which departs from the standard by replacing the old value with the new one rather than concatenating the new value to the old one
  • - getAllResponseHeaders() + getResponseHeader( name )
  • - getResponseHeader() + overrideMimeType( mimeType )
  • - statusCode() + setRequestHeader( name, value ) which departs from the standard by replacing the old value with the new one rather than concatenating the new value to the old one
  • - abort() + statusCode( callbacksByStatusCode )
  • No onreadystatechange mechanism is provided, however, since done, fail, always, and statusCode cover all conceivable requirements.

    @@ -290,16 +334,16 @@ jqxhr.always(function() {

    Different types of response to $.ajax() call are subjected to different kinds of pre-processing before being passed to the success handler. The type of pre-processing depends by default upon the Content-Type of the response, but can be set explicitly using the dataType option. If the dataType option is provided, the Content-Type header of the response will be disregarded.

    The available data types are text, html, xml, json, jsonp, and script.

    If text or html is specified, no pre-processing occurs. The data is simply passed on to the success handler, and made available through the responseText property of the jqXHR object.

    -

    If xml is specified, the response is parsed using jQuery.parseXML before being passed, as an XMLDocument, to the success handler. The XML document is made available through the responseXML property of the jqXHR object.

    +

    If xml is specified, the response is parsed using jQuery.parseXML before being passed, as an XMLDocument, to the success handler. The XML document is made available through the responseXML property of the jqXHR object.

    If json is specified, the response is parsed using jQuery.parseJSON before being passed, as an object, to the success handler. The parsed JSON object is made available through the responseJSON property of the jqXHR object.

    If script is specified, $.ajax() will execute the JavaScript that is received from the server before passing it on to the success handler as a string.

    If jsonp is specified, $.ajax() will automatically append a query string parameter of (by default) callback=? to the URL. The jsonp and jsonpCallback properties of the settings passed to $.ajax() can be used to specify, respectively, the name of the query string parameter and the name of the JSONP callback function. The server should return valid JavaScript that passes the JSON response into the callback function. $.ajax() will execute the returned JavaScript, calling the JSONP callback function, before passing the JSON object contained in the response to the $.ajax() success handler.

    -

    For more information on JSONP, see the original post detailing its use.

    +

    For more information on JSONP, see the original post detailing its use.

    Sending Data to the Server

    By default, Ajax requests are sent using the GET HTTP method. If the POST method is required, the method can be specified by setting a value for the type option. This option affects how the contents of the data option are sent to the server. POST data will always be transmitted to the server using UTF-8 charset, per the W3C XMLHTTPRequest standard.

    The data option can contain either a query string of the form key1=value1&key2=value2, or an object of the form {key1: 'value1', key2: 'value2'}. If the latter form is used, the data is converted into a query string using jQuery.param() before it is sent. This processing can be circumvented by setting processData to false. The processing might be undesirable if you wish to send an XML object to the server; in this case, change the contentType option from application/x-www-form-urlencoded to a more appropriate MIME type.

    Advanced Options

    -

    The global option prevents handlers registered using .ajaxSend(), .ajaxError(), and similar methods from firing when this request would trigger them. This can be useful to, for example, suppress a loading indicator that was implemented with .ajaxSend() if the requests are frequent and brief. With cross-domain script and JSONP requests, the global option is automatically set to false. See the descriptions of these methods below for more details.

    +

    The global option prevents handlers registered for the ajaxSend, ajaxError, and similar events from firing when this request would trigger them. This can be useful to, for example, suppress a loading indicator that was implemented with an ajaxSend handler if the requests are frequent and brief. With cross-domain script and JSONP requests, the global option is automatically set to false. See the descriptions of these methods below for more details.

    If the server performs HTTP authentication before providing a response, the user name and password pair can be sent via the username and password options.

    Ajax requests are time-limited, so errors can be caught and handled to provide a better user experience. Request timeouts are usually either left at their default or set as a global default using $.ajaxSetup() rather than being overridden for specific requests with the timeout option.

    By default, requests are always issued, but the browser may serve results out of its cache. To disallow use of the cached results, set cache to false. To cause the request to report failure if the asset has not been modified since the last request, set ifModified to true.

    @@ -311,7 +355,7 @@ jqxhr.always(function() {

    As of jQuery 1.5, jQuery's Ajax implementation includes prefilters, transports, and converters that allow you to extend Ajax with a great deal of flexibility.

    Using Converters

    -

    $.ajax() converters support mapping data types to other data types. If, however, you want to map a custom data type to a known type (e.g json), you must add a correspondance between the response Content-Type and the actual data type using the contents option:

    +

    $.ajax() converters support mapping data types to other data types. If, however, you want to map a custom data type to a known type (e.g json), you must add a correspondence between the response Content-Type and the actual data type using the contents option:

    
     $.ajaxSetup({
       contents: {
    @@ -325,7 +369,7 @@ $.ajaxSetup({
       }
     });
         
    -

    This extra object is necessary because the response Content-Types and data types never have a strict one-to-one correspondance (hence the regular expression).

    +

    This extra object is necessary because the response Content-Types and data types never have a strict one-to-one correspondence (hence the regular expression).

    To convert from a supported type (e.g text, json) to a custom data type and back again, use another pass-through converter:

    
     $.ajaxSetup({
    @@ -418,4 +462,6 @@ $.ajax({
       
       
       
    +  
    +  
     
    diff --git a/entries/jQuery.ajaxPrefilter.xml b/entries/jQuery.ajaxPrefilter.xml
    index eb762dfb..708ca829 100644
    --- a/entries/jQuery.ajaxPrefilter.xml
    +++ b/entries/jQuery.ajaxPrefilter.xml
    @@ -24,7 +24,7 @@ $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
         

    where:

    • options are the request options
    • -
    • originalOptions are the options as provided to the ajax method, unmodified and, thus, without defaults from ajaxSettings
    • +
    • originalOptions are the options as provided to the $.ajax() method, unmodified and, thus, without defaults from ajaxSettings
    • jqXHR is the jqXHR object of the request

    Prefilters are a perfect fit when custom options need to be handled. Given the following code, for example, a call to $.ajax() would automatically abort a request to the same URL if the custom abortOnRetry option is set to true:

    @@ -40,11 +40,11 @@ $.ajaxPrefilter(function( options, originalOptions, jqXHR ) { } });
    -

    Prefilters can also be used to modify existing options. For example, the following proxies cross-domain requests through http://mydomain.net/proxy/:

    +

    Prefilters can also be used to modify existing options. For example, the following proxies cross-domain requests through https://mydomain.net/proxy/:

    
     $.ajaxPrefilter(function( options ) {
       if ( options.crossDomain ) {
    -    options.url = "http://mydomain.net/proxy/" + encodeURIComponent( options.url );
    +    options.url = "https://mydomain.net/proxy/" + encodeURIComponent( options.url );
         options.crossDomain = false;
       }
     });
    diff --git a/entries/jQuery.ajaxSetup.xml b/entries/jQuery.ajaxSetup.xml
    index d9589e3a..b0b54447 100644
    --- a/entries/jQuery.ajaxSetup.xml
    +++ b/entries/jQuery.ajaxSetup.xml
    @@ -1,5 +1,5 @@
     
    -
    +
       jQuery.ajaxSetup()
       
         1.1
    @@ -26,7 +26,7 @@ $.ajax({
     });
         
    -

    Note: Global callback functions should be set with their respective global Ajax event handler methods—.ajaxStart(), .ajaxStop(), .ajaxComplete(), .ajaxError(), .ajaxSuccess(), .ajaxSend()—rather than within the options object for $.ajaxSetup().

    +

    Note: Global callback functions should be set via .on() with their respective global Ajax events—ajaxStart, ajaxStop, ajaxComplete, ajaxError, ajaxSuccess, ajaxSend—rather than within the options object for $.ajaxSetup().

    diff --git a/entries/jQuery.ajaxTransport.xml b/entries/jQuery.ajaxTransport.xml index ab8e4d9b..ccc73ce8 100644 --- a/entries/jQuery.ajaxTransport.xml +++ b/entries/jQuery.ajaxTransport.xml @@ -35,10 +35,10 @@ $.ajaxTransport( dataType, function( options, originalOptions, jqXHR ) {

    where:

    • options are the request options
    • -
    • originalOptions are the options as provided to the ajax method, unmodified and, thus, without defaults from ajaxSettings
    • +
    • originalOptions are the options as provided to the $.ajax() method, unmodified and, thus, without defaults from ajaxSettings
    • jqXHR is the jqXHR object of the request
    • headers is an object of (key-value) request headers that the transport can transmit if it supports it
    • -
    • completeCallback is the callback used to notify ajax of the completion of the request
    • +
    • completeCallback is the callback used to notify Ajax of the completion of the request

    completeCallback has the following signature:

    
    @@ -48,7 +48,7 @@ function( status, statusText, responses, headers ) {}
         
    • status is the HTTP status code of the response, like 200 for a typical success, or 404 for when the resource is not found.
    • statusText is the statusText of the response.
    • -
    • responses (Optional) is An object containing dataType/value that contains the response in all the formats the transport could provide (for instance, a native XMLHttpRequest object would set reponses to { xml: XMLData, text: textData } for a response that is an XML document)
    • +
    • responses (Optional) is An object containing dataType/value that contains the response in all the formats the transport could provide (for instance, a native XMLHttpRequest object would set responses to { xml: XMLData, text: textData } for a response that is an XML document)
    • headers (Optional) is a string containing all the response headers if the transport has access to them (akin to what XMLHttpRequest.getAllResponseHeaders() would provide).

    Just like prefilters, a transport's factory function can be attached to a specific dataType:

    diff --git a/entries/jQuery.boxModel.xml b/entries/jQuery.boxModel.xml index f260538a..b80abe29 100644 --- a/entries/jQuery.boxModel.xml +++ b/entries/jQuery.boxModel.xml @@ -4,8 +4,12 @@ 1.0 - States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model. This property was removed in jQuery 1.8. Please try to use feature detection instead. - + States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model. + +
    +

    Note: This API has been removed in jQuery 3.0; check if .document.compatMode is equal to "CSS1Compat" instead. Or, even better - always specify a DOCTYPE and avoid using quirks mode which jQuery doesn't support.

    +
    +
    diff --git a/entries/jQuery.browser.xml b/entries/jQuery.browser.xml index e7c690ac..11686eae 100644 --- a/entries/jQuery.browser.xml +++ b/entries/jQuery.browser.xml @@ -7,6 +7,9 @@ Contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead. +
    +

    Note: This API has been removed in jQuery 1.9; please rely on feature detection instead.

    +

    The $.browser property provides information about the web browser that is accessing the page, as reported by the browser itself. It contains flags for each of the four most prevalent browser classes (Internet Explorer, Mozilla, Webkit, and Opera) as well as version information.

    Available flags are:

      @@ -18,7 +21,7 @@

    This property is available immediately. It is therefore safe to use it to determine whether or not to call $(document).ready(). The $.browser property is deprecated in jQuery 1.3, and its functionality may be moved to a team-supported plugin in a future release of jQuery.

    -

    Because $.browser uses navigator.userAgent to determine the platform, it is vulnerable to spoofing by the user or misrepresentation by the browser itself. It is always best to avoid browser-specific code entirely where possible. Instead of relying on $.browser it's better to use libraries like Modernizr.

    +

    Because $.browser uses navigator.userAgent to determine the platform, it is vulnerable to spoofing by the user or misrepresentation by the browser itself. It is always best to avoid browser-specific code entirely where possible. Instead of relying on $.browser it's better to use libraries like Modernizr.

    Show the browser info. @@ -56,6 +59,9 @@ $.browser.msie; The version number of the rendering engine for the user's browser. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. +
    +

    Note: This API has been removed in jQuery 1.9; please rely on feature detection instead.

    +

    Here are some typical results:

    • Internet Explorer: 6.0, 7.0, 8.0
    • diff --git a/entries/jQuery.cssHooks.xml b/entries/jQuery.cssHooks.xml index f7ecb170..ec36ccfe 100644 --- a/entries/jQuery.cssHooks.xml +++ b/entries/jQuery.cssHooks.xml @@ -45,7 +45,7 @@ function styleSupport( prop ) { // Capitalize first character of the prop to test vendor prefix capProp = prop.charAt( 0 ).toUpperCase() + prop.slice( 1 ), - prefixes = [ "Moz", "Webkit", "O", "ms" ], + prefixes = [ "Moz", "Webkit", "ms" ], div = document.createElement( "div" ); if ( prop in div.style ) { @@ -89,7 +89,7 @@ if ( !$.cssHooks ) { function styleSupport( prop ) { var vendorProp, supportedProp, capProp = prop.charAt( 0 ).toUpperCase() + prop.slice( 1 ), - prefixes = [ "Moz", "Webkit", "O", "ms" ], + prefixes = [ "Moz", "Webkit", "ms" ], div = document.createElement( "div" ); if ( prop in div.style ) { @@ -163,7 +163,7 @@ if ( $.support.someCSSProp && $.support.someCSSProp !== "someCSSProp" ) })( jQuery );

    Special units

    -

    By default, jQuery adds a "px" unit to the values passed to the .css() method. This behavior can be prevented by adding the property to the jQuery.cssNumber object

    +

    By default, jQuery adds a "px" unit to the values passed to the .css() method. This behavior can be prevented by adding the property to the jQuery.cssNumber object

    
     $.cssNumber.someCSSProp = true;
         
    diff --git a/entries/jQuery.cssNumber.xml b/entries/jQuery.cssNumber.xml index ce5af886..c49b3c78 100644 --- a/entries/jQuery.cssNumber.xml +++ b/entries/jQuery.cssNumber.xml @@ -1,30 +1,50 @@ - + jQuery.cssNumber 1.4.3 - An object containing all CSS properties that may be used without a unit. The .css() method uses this object to see if it may append px to unitless values. + An object containing all CSS properties that may be used without a unit. Prior to jQuery 4.0, the .css() method uses this object to see if it may append px to unitless values. -

    You can think about jQuery.cssNumber as a list of all CSS properties you might use without a unit. It's used by .css() to determine if it needs to add px to unitless values.

    -

    The keys of the jQuery.cssNumber object are camel-cased and the values are all set to true. If you want to prevent the .css() method from automatically adding the px unit for a specific CSS property, you can add an extra property to the jQuery.cssNumber object.

    +
    +

    Note: This API has been removed in jQuery 4.0; please pass a string value with the desired units instead.

    +
    +

    You can think about jQuery.cssNumber as a list of all CSS properties you might use without a unit. Prior to jQuery 4.0, it was used by .css() to determine if it needs to add px to unitless values.

    +

    The keys of the jQuery.cssNumber object are camel-cased and the values are all set to true. If you want to prevent the .css() method from automatically adding the px unit for a specific CSS property and that property is not yet a key of the jQuery.cssNumber object, you can add such an extra property:

    
    -jQuery.cssNumber.someCSSProp = true;
    +if ( jQuery.cssNumber ) {
    +  jQuery.cssNumber.someCSSProp = true;
    +}
         

    By default the object contains the following properties:

      -
    • zIndex
    • -
    • fontWeight
    • -
    • opacity
    • -
    • zoom
    • -
    • lineHeight
    • -
    • widows (added in jQuery 1.6)
    • -
    • orphans (added in jQuery 1.6)
    • -
    • fillOpacity (added in jQuery 1.6.2)
    • -
    • columnCount (added in jQuery 1.9)
    • -
    • order (added in jQuery 1.10.2)
    • -
    • flexGrow (added in jQuery 1.11.1)
    • -
    • flexShrink (added in jQuery 1.11.1)
    • +
    • animationIterationCount (added in 1.12.0/2.2.0)
    • +
    • aspectRatio (added in 3.7.0)
    • +
    • borderImageSlice (added in 3.7.0)
    • +
    • columnCount (added in 1.9.0)
    • +
    • flexGrow (added in 1.11.1/2.1.1)
    • +
    • flexShrink (added in 1.11.1/2.1.1)
    • +
    • fontWeight (added in 1.4.3)
    • +
    • gridArea (added in 3.4.0)
    • +
    • gridColumn (added in 3.4.0)
    • +
    • gridColumnEnd (added in 3.4.0)
    • +
    • gridColumnStart (added in 3.4.0)
    • +
    • gridRow (added in 3.4.0)
    • +
    • gridRowEnd (added in 3.4.0)
    • +
    • gridRowStart (added in 3.4.0)
    • +
    • lineHeight (added in 1.4.3)
    • +
    • opacity (added in 1.4.3)
    • +
    • order (added in 1.10.2/2.0.3)
    • +
    • orphans (added in 1.6.0)
    • +
    • scale (added in 3.7.0)
    • +
    • widows (added in 1.6.0)
    • +
    • zIndex (added in 1.4.3)
    • +
    • zoom (added in 1.4.3)
    • +
    • fillOpacity (SVG-related, added in 1.6.2)
    • +
    • floodOpacity (SVG-related, added in 3.7.0)
    • +
    • stopOpacity (SVG-related, added in 3.7.0)
    • +
    • strokeMiterlimit (SVG-related, added in 3.7.0)
    • +
    • strokeOpacity (SVG-related, added in 3.7.0)
    diff --git a/entries/jQuery.data.xml b/entries/jQuery.data.xml index 193cae70..5207c8b8 100644 --- a/entries/jQuery.data.xml +++ b/entries/jQuery.data.xml @@ -25,7 +25,7 @@ jQuery.data( document.body, "bar", "test" );
    - + Store then retrieve a value from the div element. Get the data named "blah" stored at for an element. Use jQuery.dequeue() to end a custom queue function which allows the queue to keep going. jQuery.each() 1.0 - - The array to iterate over. + + The array or array-like object to iterate over. - The function that will be executed on every object. + The function that will be executed on every value. @@ -20,13 +20,12 @@ - The function that will be executed on every object. + The function that will be executed on every value. A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.

    The $.each() function is not the same as $(selector).each(), which is used to iterate, exclusively, over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array. In the case of an array, the callback is passed an array index and a corresponding array value each time. (The value can also be accessed through the this keyword, but Javascript will always wrap the this value as an Object even if it is a simple string or number value.) The method returns its first argument, the object that was iterated.

    -

    Note: The $.each() function internally retrieves and uses the length property of the passed collection. So, if the collection has a property called length — e.g. {bar: 'foo', length: 10} — the function might not work as expected.

    
     $.each([ 52, 97 ], function( index, value ) {
       alert( index + ": " + value );
    diff --git a/entries/jQuery.error.xml b/entries/jQuery.error.xml
    index 3ae5110a..54b64d5d 100644
    --- a/entries/jQuery.error.xml
    +++ b/entries/jQuery.error.xml
    @@ -10,11 +10,15 @@
       Takes a string and throws an exception containing it.
       
         

    This method exists primarily for plugin developers who wish to override it and provide a better display (or more information) for the error messages.

    +

    If you do override the method, remember to still throw an error at the end to preserve semantics.

    - Override jQuery.error for display in Firebug. + Override jQuery.error to send it to a logging service, assuming the sendErrorLog method is provided by this service. diff --git a/entries/jQuery.escapeSelector.xml b/entries/jQuery.escapeSelector.xml new file mode 100644 index 00000000..9e9a91d1 --- /dev/null +++ b/entries/jQuery.escapeSelector.xml @@ -0,0 +1,29 @@ + + + jQuery.escapeSelector() + Escapes any character that has a special meaning in a CSS selector. + + 3.0 + + A string containing a selector expression to escape. + + + +

    This method is useful for situations where a class name or an ID contains characters that have a special meaning in CSS, such as the dot or the semicolon.

    +

    The method is essentially a shim for the CSS Working Group's CSS.escape() method. The main difference is that $.escapeSelector() can be reliably used in all of jQuery's supported browsers.

    +
    + + Escape an ID containing a hash. + + + + Select all the elements having a class name of .box inside a div. + + + + +
    diff --git a/entries/jQuery.extend.xml b/entries/jQuery.extend.xml index ee6fb4a7..47262615 100644 --- a/entries/jQuery.extend.xml +++ b/entries/jQuery.extend.xml @@ -4,9 +4,9 @@ 1.0 - An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. + An object that will receive the new properties. - + An object containing additional properties to merge in. @@ -16,7 +16,7 @@ 1.1.4 - If true, the merge becomes recursive (aka. deep copy). + If true, the merge becomes recursive (aka. deep copy). Passing false for this argument is not supported. The object to extend. It will receive the new properties. @@ -28,6 +28,12 @@ Additional objects containing properties to merge in. + + 1.0 + + An object to merge onto the jQuery namespace. + + Merge the contents of two or more objects together into the first object.

    When two or more object arguments are supplied to $.extend(), properties from all of the objects are added to the target object. Arguments that are null or undefined are ignored.

    @@ -35,10 +41,11 @@

    Keep in mind that the target object (first argument) will be modified, and will also be returned from $.extend(). If, however, you want to preserve both of the original objects, you can do so by passing an empty object as the target:

    var object = $.extend({}, object1, object2);

    The merge performed by $.extend() is not recursive by default; if a property of the first object is itself an object or array, it will be completely overwritten by a property with the same key in the second or subsequent object. The values are not merged. This can be seen in the example below by examining the value of banana. However, by passing true for the first function argument, objects will be recursively merged.

    +

    Warning: Versions prior to 3.4 had a security issue where calling jQuery.extend(true, {}, object) on an unsanitized object containing a __proto__ property would extend Object.prototype.

    Warning: Passing false for the first argument is not supported.

    Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over. Properties that are an object constructed via new MyCustomObject(args), or built-in JavaScript types such as Date or RegExp, are not re-constructed and will appear as plain Objects in the resulting object or array.

    On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not. Deep-extending a cyclical data structure will result in an error.

    -

    For needs that fall outside of this behavior, write a custom extend method instead, or use a library like lodash.

    +

    For needs that fall outside of this behavior, write a custom extend method instead, or use a library like lodash.

    Merge two objects, modifying the first. @@ -106,4 +113,5 @@ $( "#log" ).append( "
    settings -- " + JSON.stringify( settings ) + "< + diff --git a/entries/jQuery.fx.interval.xml b/entries/jQuery.fx.interval.xml index cf67f484..b86516c3 100644 --- a/entries/jQuery.fx.interval.xml +++ b/entries/jQuery.fx.interval.xml @@ -1,19 +1,22 @@ - + jQuery.fx.interval The rate (in milliseconds) at which animations fire. 1.4.3 -

    This property can be manipulated to adjust the number of frames per second at which animations will run. The default is 13 milliseconds. Making this a lower number could make the animations run smoother in faster browsers (such as Chrome) but there may be performance and CPU implications of doing so.

    +
    +

    This property is deprecated as of version 3.0, and has no effect in browsers that support the requestAnimationFrame method.

    +
    +

    On browsers that do not support requestAnimationFrame, this property can be changed to adjust the interval at which animations will run. The default is 13 milliseconds.

    Since jQuery uses one global interval, no animation should be running or all animations should stop for the change of this property to take effect.

    Cause all animations to run with less frames. @@ -34,4 +37,5 @@ $( "input" ).click(function() { +
    diff --git a/entries/jQuery.fx.off.xml b/entries/jQuery.fx.off.xml index 74bfd60a..8464f69f 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" ); -}); +} ); ]]>
    jQuery.get() - - 3.0 - - A set of key/value pairs that configure the Ajax request. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) for a complete list of all settings. The type option will automatically be set to GET. - - 1.0 @@ -21,10 +15,16 @@ - A callback function that is executed if the request succeeds. + A callback function that is executed if the request succeeds. Required if dataType is provided, but you can use null or jQuery.noop as a placeholder. - The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + + + + 1.12-and-2.2 + + A set of key/value pairs that configure the Ajax request. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) for a complete list of all settings. The type option will automatically be set to GET. Load data from the server using a HTTP GET request. @@ -49,7 +49,7 @@ $.get( "ajax/test.html", function( data ) {

    This example fetches the requested HTML snippet and inserts it on the page.

    The jqXHR Object

    -

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.get() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    +

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.get() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    The Promise interface also allows jQuery's Ajax methods, including $.get(), to chain multiple .done(), .fail(), and .always() callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.

    
     // Assign handlers immediately after making the request,
    @@ -75,7 +75,7 @@ jqxhr.always(function() {
     });
         

    Deprecation Notice

    -

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods introduced in jQuery 1.5 are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    +

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    @@ -116,16 +116,28 @@ $.get( "test.cgi", { name: "John", time: "2pm" } ) ]]>
    - Get the test.php page contents, which has been returned in json format (<?php echo json_encode( array( "name"=>"John","time"=>"2pm" ) ); ?>), and add it to the page. + Get the test.php page contents, which has been returned in json format (<?php echo json_encode( array( "name"=>"John","time"=>"2pm" ) ); ?>), and add it to the page. + + + Get another page on the same domain. Outputs to console both the data returned and the type of data returned. + + diff --git a/entries/jQuery.getJSON.xml b/entries/jQuery.getJSON.xml index 97c8b0a9..1449293d 100644 --- a/entries/jQuery.getJSON.xml +++ b/entries/jQuery.getJSON.xml @@ -56,12 +56,12 @@ $.getJSON( "ajax/test.json", function( data ) {

    The success callback is passed the returned data, which is typically a JavaScript object or array as defined by the JSON structure and parsed using the $.parseJSON() method. It is also passed the text status of the response.

    As of jQuery 1.5, the success callback function receives a "jqXHR" object (in jQuery 1.4, it received the XMLHttpRequest object). However, since JSONP and cross-domain GET requests do not use XHR, in those cases the jqXHR and textStatus parameters passed to the success callback are undefined.

    -

    Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript's object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see http://json.org/.

    +

    Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript's object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see https://json.org/.

    JSONP

    If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

    The jqXHR Object

    -

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.getJSON() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    +

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.getJSON() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including $.getJSON(), to chain multiple .done(), .always(), and .fail() callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.

    
     // Assign handlers immediately after making the request,
    @@ -82,12 +82,12 @@ var jqxhr = $.getJSON( "example.json", function() {
     // Perform other work here ...
     
     // Set another completion function for the request above
    -jqxhr.complete(function() {
    +jqxhr.always(function() {
       console.log( "second complete" );
     });
         

    Deprecation Notice

    -

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods introduced in jQuery 1.5 are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    +

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    @@ -95,7 +95,7 @@ jqxhr.complete(function() { Loads the four most recent pictures of Mount Rainier from the Flickr JSONP API. Success Callback -

    The callback is fired once the script has been loaded but not necessarily executed.

    +

    The callback is fired once the script has been loaded and executed.

    Scripts are included and run by referencing the file name:

    
     $.getScript( "ajax/test.js", function( data, textStatus, jqxhr ) {
    @@ -48,14 +48,15 @@ $.getScript( "ajax/test.js" )
         $( "div.log" ).text( "Triggered ajaxError handler." );
     });
         
    -

    Prior to jQuery 1.5, the global .ajaxError() callback event had to be used in order to handle $.getScript() errors:

    +

    Prior to jQuery 1.5, the global ajaxError callback event had to be used in order to handle $.getScript() errors:

    
    -$( "div.log" ).ajaxError(function( e, jqxhr, settings, exception ) {
    +$( "div.log" ).on( "ajaxError", function( e, jqxhr, settings, exception ) {
       if ( settings.dataType == "script" ) {
         $( this ).text( "Triggered ajaxError handler." );
       }
    -});
    +} );
         
    +

    Prior to jQuery 3.5.0, unsuccessful HTTP responses with a script Content-Type were still executed.

    Caching Responses

    By default, $.getScript() sets the cache setting to false. This appends a timestamped query parameter to the request URL to ensure that the browser downloads the script each time it is requested. You can override this feature by setting the cache property globally using $.ajaxSetup():

    
    @@ -91,9 +92,9 @@ $.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {
       
         Load the official jQuery Color Animation plugin dynamically and bind some color animations to occur once the new functionality is loaded.
         
       
       
    +  
     
    diff --git a/entries/jQuery.globalEval.xml b/entries/jQuery.globalEval.xml
    index ce510fe3..f6234efe 100644
    --- a/entries/jQuery.globalEval.xml
    +++ b/entries/jQuery.globalEval.xml
    @@ -1,5 +1,5 @@
     
    -
    +
       jQuery.globalEval()
       
         1.0.4
    @@ -7,6 +7,31 @@
           The JavaScript code to execute.
         
       
    +  
    +    3.4
    +    
    +      The JavaScript code to execute.
    +    
    +    
    +      
    +        The nonce attribute passed to the executed script.
    +      
    +    
    +  
    +  
    +    3.5
    +    
    +      The JavaScript code to execute.
    +    
    +    
    +      
    +        The nonce attribute passed to the executed script.
    +      
    +    
    +    
    +      A document in which context the code will be evaluated.
    +    
    +  
       Execute some JavaScript code globally.
       
         

    This method behaves differently from using a normal JavaScript eval() in that it's executed within the global context (which is important for loading external scripts dynamically).

    @@ -15,7 +40,19 @@ Execute a script in the global context. +
    + + Execute a script with a nonce value on a site with Content Security Policy enabled. + Finds the elements of an array which satisfy a filter function. The original array is not affected. 1.0 - - The array to search through. + + The array-like object to search through. diff --git a/entries/jQuery.hasData.xml b/entries/jQuery.hasData.xml index af081d41..ece74c75 100644 --- a/entries/jQuery.hasData.xml +++ b/entries/jQuery.hasData.xml @@ -9,7 +9,7 @@ Determine whether an element has any jQuery data associated with it. -

    The jQuery.hasData() method provides a way to determine if an element currently has any values that were set using jQuery.data(). If no data is associated with an element (there is no data object at all or the data object is empty), the method returns false; otherwise it returns true.

    +

    The jQuery.hasData() method provides a way to determine if an element currently has any values that were set using jQuery.data(). If there is no data object associated with an element, the method returns false; otherwise it returns true.

    The primary advantage of jQuery.hasData(element) is that it does not create and associate a data object with the element if none currently exists. In contrast, jQuery.data(element) always returns a data object to the caller, creating one if no data object previously existed.

    Note that jQuery's event system uses the jQuery data API to store event handlers. Therefore, binding an event to an element using .on(), .bind(), .live(), .delegate(), or one of the shorthand event methods also associates a data object with that element. diff --git a/entries/jQuery.holdReady.xml b/entries/jQuery.holdReady.xml index cb795f2f..0ba8ceb0 100644 --- a/entries/jQuery.holdReady.xml +++ b/entries/jQuery.holdReady.xml @@ -1,5 +1,5 @@ - + jQuery.holdReady() Holds or releases the execution of jQuery's ready event. @@ -9,6 +9,16 @@ +

    +

    Note: This API has been deprecated in jQuery 3.2. Instead of relying on this global switch, it's better to put explicitly wait for required code. If you need to wait both for the ready state & for a custom promise, use the following pattern:

    + +

    The $.holdReady() method allows the caller to delay jQuery's ready event. This advanced feature would typically be used by dynamic script loaders that want to load additional JavaScript such as jQuery plugins before allowing the ready event to occur, even though the DOM may be ready. This method must be called early in the document, such as in the <head> immediately after the jQuery script tag. Calling this method after the ready event has already fired will have no effect.

    To delay the ready event, first call $.holdReady( true ). When the ready event should be released to execute, call $.holdReady( false ). Note that multiple holds can be put on the ready event, one for each $.holdReady( true ) call. The ready event will not actually fire until all holds have been released with a corresponding number of $.holdReady( false ) calls and the normal document ready conditions are met. (See ready for more information.)

    @@ -22,5 +32,8 @@ $.getScript( "myplugin.js", function() { ]]>
    + + + diff --git a/entries/jQuery.htmlPrefilter.xml b/entries/jQuery.htmlPrefilter.xml new file mode 100644 index 00000000..75381903 --- /dev/null +++ b/entries/jQuery.htmlPrefilter.xml @@ -0,0 +1,17 @@ + + + jQuery.htmlPrefilter() + Modify and filter HTML strings passed through jQuery manipulation methods. + + 1.12-and-2.2 + + The HTML string on which to operate. + + + +

    This method rarely needs to be called directly. Instead, use it as an entry point to modify existing jQuery manipulation methods. jQuery calls this method on input HTML before processing it further: it accepts an HTML string & should return a HTML string as well.

    +

    This function can also be overwritten in order to bypass certain edge case issues. The default htmlPrefilter function in jQuery leaves input unmodified since 3.5.0. Older versions would greedily ensure that all tags were XHTML-compliant. This included anything that looked like an HTML tag, but was actually within a string (e.g. <a title="<div />"><>), leading to potential security issues. For more information, see the jQuery Core 3.5 Upgrade guide.

    +
    + + +
    diff --git a/entries/jQuery.isArray.xml b/entries/jQuery.isArray.xml index 6f040c4e..9891126f 100644 --- a/entries/jQuery.isArray.xml +++ b/entries/jQuery.isArray.xml @@ -1,5 +1,5 @@ - + jQuery.isArray() 1.3 @@ -9,6 +9,9 @@ Determine whether the argument is an array. +
    +

    Note: This API has been deprecated in jQuery 3.2; please use the native Array.isArray method instead.

    +

    $.isArray() returns a Boolean indicating whether the object is a JavaScript array (not an array-like object, such as a jQuery object).

    @@ -22,4 +25,5 @@ Is [] an Array? +
    diff --git a/entries/jQuery.isFunction.xml b/entries/jQuery.isFunction.xml index 2ceed224..5160f0a7 100644 --- a/entries/jQuery.isFunction.xml +++ b/entries/jQuery.isFunction.xml @@ -1,14 +1,17 @@ - + jQuery.isFunction() 1.2 - - Object to test whether or not it is a function. + + The value to be tested. - Determine if the argument passed is a Javascript function object. + Determines if its argument is callable as a function. +
    +

    As of jQuery 3.3, jQuery.isFunction() has been deprecated. In most cases, its use can be replaced by typeof x === "function".

    +

    Note: As of jQuery 1.3, functions provided by the browser like alert() and DOM element methods like getAttribute() are not guaranteed to be detected as functions in browsers such as Internet Explorer.

    @@ -57,4 +60,5 @@ true +
    diff --git a/entries/jQuery.isNumeric.xml b/entries/jQuery.isNumeric.xml index 80edc02d..c4fe4a72 100644 --- a/entries/jQuery.isNumeric.xml +++ b/entries/jQuery.isNumeric.xml @@ -1,36 +1,46 @@ - + jQuery.isNumeric() - Determines whether its argument is a number. + Determines whether its argument represents a JavaScript number. 1.7 - + The value to be tested. +
    +

    Note: This API has been deprecated in jQuery 3.3.

    +

    The $.isNumeric() method checks whether its argument represents a numeric value. If so, it returns true. Otherwise it returns false. The argument can be of any type.

    +

    As of jQuery 3.0 $.isNumeric() returns true only if the argument is of type number, or if it's of type string and it can be coerced into finite numbers. In all other cases, it returns false.

    Sample return values of $.isNumeric with various inputs. +
    diff --git a/entries/jQuery.isWindow.xml b/entries/jQuery.isWindow.xml index 15453599..76a58f17 100644 --- a/entries/jQuery.isWindow.xml +++ b/entries/jQuery.isWindow.xml @@ -1,5 +1,5 @@ - + jQuery.isWindow() 1.4.3 @@ -9,6 +9,12 @@ Determine whether the argument is a window. +
    +

    Note: This API has been deprecated in jQuery 3.3; if you need this function, reimplement it by yourself:

    + +

    This is used in a number of places in jQuery to determine if we're operating against a browser window (such as the current window or an iframe).

    @@ -22,4 +28,5 @@ Is 'window' a window? +
    diff --git a/entries/jQuery.map.xml b/entries/jQuery.map.xml index 3c499e6c..2016df87 100644 --- a/entries/jQuery.map.xml +++ b/entries/jQuery.map.xml @@ -3,8 +3,8 @@ jQuery.map() 1.0 - - The Array to translate. + + The Array or an Array-like object to translate. @@ -16,7 +16,7 @@ 1.6 - The Object to translate. + The non-Array-like Object to translate. @@ -28,16 +28,13 @@ Translate all items in an array or object to new array of items.

    If you wish to process a jQuery object — for example, $('div').map( callback ); — use .map() instead.

    -

    The $.map() method applies a function to each item in an array or object and maps the results into a new array. Prior to jQuery 1.6, $.map() supports traversing arrays only. As of jQuery 1.6 it also traverses objects.

    -

    Array-like objects — those with a .length property and a value on the .length - 1 index — must be converted to actual arrays before being passed to $.map(). The jQuery library provides $.makeArray() for such conversions.

    +

    The $.map() method applies a function to each item in an array or object and maps the results into a new array. Prior to jQuery 1.6, $.map() supports traversing arrays and array-like objects only. As of jQuery 1.6 it also traverses objects.

    +

    Array-like objects — those with a .length property and a value on the .length - 1 index — may be passed to $.map().

    
    -// The following object masquerades as an array.
    +// The following object is array-like.
     var fakeArray = { "length": 2, 0: "Addy", 1: "Subtracty" };
     
    -// Therefore, convert it to a real array
    -var realArray = $.makeArray( fakeArray )
    -
    -// Now it can be used reliably with $.map()
    +// It can be used reliably with $.map()
     $.map( realArray, function( val, i ) {
       // Do something
     });
    diff --git a/entries/jQuery.merge.xml b/entries/jQuery.merge.xml
    index ef43c770..b122635e 100644
    --- a/entries/jQuery.merge.xml
    +++ b/entries/jQuery.merge.xml
    @@ -4,15 +4,15 @@
       Merge the contents of two arrays together into the first array. 
       
         1.0
    -    
    -      The first array to merge, the elements of second added.
    +    
    +      The first array-like object to merge, the elements of second added.
         
    -    
    -      The second array to merge into the first, unaltered.
    +    
    +      The second array-like object to merge into the first, unaltered.
         
       
       
    -    

    The $.merge() operation forms an array that contains all elements from the two arrays. The orders of items in the arrays are preserved, with items from the second array appended. The $.merge() function is destructive. It alters the first parameter to add the items from the second.

    +

    The $.merge() operation forms an array that contains all elements from the two arrays. The orders of items in the arrays are preserved, with items from the second array appended. The $.merge() function is destructive. It alters the length and numeric index properties of the first object to include items from the second.

    If you need the original first array, make a copy of it before calling $.merge(). Fortunately, $.merge() itself can be used for this duplication:

    
     var newArray = $.merge([], oldArray);
    diff --git a/entries/jQuery.now.xml b/entries/jQuery.now.xml
    index 6c41af36..00992aba 100644
    --- a/entries/jQuery.now.xml
    +++ b/entries/jQuery.now.xml
    @@ -1,13 +1,17 @@
     
    -
    +
       jQuery.now()
       
         1.4.3
       
       Return a number representing the current time.
       
    -    

    The $.now() method is a shorthand for the number returned by the expression (new Date).getTime().

    +
    +

    Note: This API has been deprecated in jQuery 3.3; please use the native Date.now() method instead.

    +
    +

    The $.now() method is an alias for Date.now().

    -
    \ No newline at end of file + +
    diff --git a/entries/jQuery.param.xml b/entries/jQuery.param.xml index 468b6db9..9a80fc2b 100644 --- a/entries/jQuery.param.xml +++ b/entries/jQuery.param.xml @@ -27,7 +27,7 @@

    This function is used internally to convert form element values into a serialized string representation (See .serialize() for more information).

    As of jQuery 1.3, the return value of a function is used instead of the function as a String.

    As of jQuery 1.4, the $.param() method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by setting jQuery.ajaxSettings.traditional = true;.

    -

    As of jQuery 1.8, the $.param() method no longer uses jQuery.ajaxSettings.traditional as its default setting and will default to false. For best compatibility across versions, call $.param() with an explicit value for the second argument and do not use defaults.

    +

    As of jQuery 3.0, the $.param() method no longer uses jQuery.ajaxSettings.traditional as its default setting and will default to false. For best compatibility across versions, call $.param() with an explicit value for the second argument and do not use defaults.

    If the object passed is in an Array, it must be an array of objects in the format returned by .serializeArray()

    
     [
    diff --git a/entries/jQuery.parseHTML.xml b/entries/jQuery.parseHTML.xml
    index 06f59937..5ff74ce7 100644
    --- a/entries/jQuery.parseHTML.xml
    +++ b/entries/jQuery.parseHTML.xml
    @@ -17,11 +17,12 @@
       
         

    jQuery.parseHTML uses native methods to convert the string to a set of DOM nodes, which can then be inserted into the document. These methods do render all trailing or leading text (even if that's just whitespace). To prevent trailing/leading whitespace from being converted to text nodes you can pass the HTML string through jQuery.trim.

    By default, the context is the current document if not specified or given as null or undefined. If the HTML was to be used in another document such as an iframe, that frame's document could be used.

    -

    Security Considerations

    -

    Most jQuery APIs that accept HTML strings will run scripts that are included in the HTML. jQuery.parseHTML does not run script in the parsed HTML unless keepScripts is explicitly true. However, it is still possible in most environments to execute script indirectly, for example via the <img onerror> attribute. The caller should be aware of this and guard against it by cleaning or escaping any untrusted inputs from sources such as the URL or cookies. For future compatibility, callers should not depend on the ability to run any script content when keepScripts is unspecified or false.

    +

    As of 3.0 the default behavior is changed. If the context is not specified or given as null or undefined, a new document is used. This can potentially improve security because inline events will not execute when the HTML is parsed. Once the parsed HTML is injected into a document it does execute, but this gives tools a chance to traverse the created DOM and remove anything deemed unsafe. This improvement does not apply to internal uses of jQuery.parseHTML as they usually pass in the current document. Therefore, a statement like $( "#log" ).append( $( htmlString ) ) is still subject to the injection of malicious code.

    +

    Security Considerations

    +

    Most jQuery APIs that accept HTML strings will run scripts that are included in the HTML. jQuery.parseHTML does not run scripts in the parsed HTML unless keepScripts is explicitly true. However, it is still possible in most environments to execute scripts indirectly, for example via the <img onerror> attribute. The caller should be aware of this and guard against it by cleaning or escaping any untrusted inputs from sources such as the URL or cookies. For future compatibility, callers should not depend on the ability to run any script content when keepScripts is unspecified or false.

    - Create an array of Dom nodes using an HTML string and insert it into a div. + Create an array of DOM nodes using an HTML string and insert it into a div.

    Content:

    diff --git a/entries/jQuery.parseJSON.xml b/entries/jQuery.parseJSON.xml index bc9dcc78..2023ebc8 100644 --- a/entries/jQuery.parseJSON.xml +++ b/entries/jQuery.parseJSON.xml @@ -1,5 +1,5 @@ - + @@ -14,6 +14,9 @@ Takes a well-formed JSON string and returns the resulting JavaScript value. +
    +

    As of jQuery 3.0, $.parseJSON is deprecated. To parse JSON strings use the native JSON.parse method instead.

    +

    Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:

    • "{test: 1}" (test does not have double quotes around it).
    • @@ -24,7 +27,7 @@
    • "NaN" (NaN cannot be represented in a JSON string; direct representation of Infinity is also not permitted).

    The JSON standard does not permit "control characters" such as a tab or newline. An example like $.parseJSON( '{ "testing":"1\t2\n3" }' ) will throw an error in most implementations because the JavaScript parser converts the string's tab and newline escapes into literal tab and newline; doubling the backslashes like "1\\t2\\n3" yields expected results. This problem is often seen when injecting JSON into a JavaScript file from a server-side language such as PHP.

    -

    Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string. For details on the JSON format, see http://json.org/.

    +

    Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string. For details on the JSON format, see https://json.org/.

    Prior to jQuery 1.9, $.parseJSON returned null instead of throwing an error if it was passed an empty string, null, or undefined, even though those are not valid JSON.

    @@ -36,4 +39,5 @@ alert( obj.name === "John" ); +
    diff --git a/entries/jQuery.post.xml b/entries/jQuery.post.xml index 2300cbe7..e5411bed 100644 --- a/entries/jQuery.post.xml +++ b/entries/jQuery.post.xml @@ -1,12 +1,6 @@ jQuery.post() - - 3.0 - - A set of key/value pairs that configure the Ajax request. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) for a complete list of all settings. Type will automatically be set to POST. - - 1.0 @@ -18,16 +12,22 @@ A plain object or string that is sent to the server with the request. - + - + A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). - Load data from the server using a HTTP POST request. + + 1.12-and-2.2 + + A set of key/value pairs that configure the Ajax request. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) for a complete list of all settings. Type will automatically be set to POST. + + + Send data to the server using a HTTP POST request.

    This is a shorthand Ajax function, which is equivalent to:

    
    @@ -50,7 +50,7 @@ $.post( "ajax/test.html", function( data ) {
         

    This example fetches the requested HTML snippet and inserts it on the page.

    Pages fetched with POST are never cached, so the cache and ifModified options in jQuery.ajaxSetup() have no effect on these requests.

    The jqXHR Object

    -

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.get() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    +

    As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.post() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation.

    The Promise interface also allows jQuery's Ajax methods, including $.get(), to chain multiple .done(), .fail(), and .always() callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.

    
     // Assign handlers immediately after making the request,
    @@ -66,7 +66,7 @@ var jqxhr = $.post( "example.php", function() {
       })
       .always(function() {
         alert( "finished" );
    -});
    +  });
     
     // Perform other work here ...
     
    @@ -77,7 +77,7 @@ jqxhr.always(function() {
         

    Deprecation Notice

    -

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods introduced in jQuery 1.5 are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    +

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    @@ -100,7 +100,7 @@ $.post( "test.php", { 'choices[]': [ "Jon", "Susan" ] } ); ]]>
    - Send form data using ajax requests + Send form data using Ajax requests @@ -132,10 +132,10 @@ $.post( "test.php", { func: "getNameAndTime" }, function( data ) { ]]>
    - Post a form using ajax and put results in a div + Post a form using Ajax and put results in a div @@ -167,4 +167,5 @@ $( "#searchForm" ).submit(function( event ) { + diff --git a/entries/jQuery.proxy.xml b/entries/jQuery.proxy.xml index e7c5f0ff..d00748b9 100644 --- a/entries/jQuery.proxy.xml +++ b/entries/jQuery.proxy.xml @@ -1,5 +1,5 @@ - + jQuery.proxy() 1.4 @@ -46,6 +46,9 @@ Takes a function and returns a new one that will always have a particular context. +
    +

    Note: This API has been deprecated in jQuery 3.3; please use the native Function.prototype.bind method instead.

    +

    This method is most useful for attaching event handlers to an element where the context is pointing back to a different object. Additionally, jQuery makes sure that even if you bind the function returned from jQuery.proxy() it will still unbind the correct function if passed the original.

    Be aware, however, that jQuery's event binding subsystem assigns a unique id to each event handling function in order to track it when it is used to specify the function to be unbound. The function represented by jQuery.proxy() is seen as a single function by the event subsystem, even when it is used to bind different contexts. To avoid unbinding the wrong handler, use a unique event namespace for binding and unbinding (e.g., "click.myproxy1") rather than specifying the proxied function during unbinding.

    As of jQuery 1.6, any number of additional arguments may be supplied to $.proxy(), and they will be passed to the function whose context will be changed.

    @@ -170,4 +173,5 @@ $( "#test" ) +
    diff --git a/entries/jQuery.queue.xml b/entries/jQuery.queue.xml index 3921e020..16fa1753 100644 --- a/entries/jQuery.queue.xml +++ b/entries/jQuery.queue.xml @@ -19,7 +19,7 @@ Show the length of the queue.
    - + 1.3 @@ -105,21 +105,21 @@ runIt(); Queue a custom function. Set a queue array to delete the queue. + + jQuery.ready + A Promise-like object (or "thenable") that resolves when the document is ready. + + 1.8 + + +

    As of jQuery 3.0, use of this object is supported via jQuery.when or the native Promise.resolve(). Code should not make assumptions about whether this object is a jQuery.Deferred, native Promise, or some other type of promise object.

    +

    See also ready(), which makes use of this.

    +
    + + Listen for document ready using jQuery.when. + + + + Typical usage involving another promise, using jQuery.when. + + + + + + +
    diff --git a/entries/jQuery.readyException.xml b/entries/jQuery.readyException.xml new file mode 100644 index 00000000..2c534ea9 --- /dev/null +++ b/entries/jQuery.readyException.xml @@ -0,0 +1,24 @@ + + + jQuery.readyException() + Handles errors thrown synchronously in functions wrapped in jQuery(). + + 3.1 + + An error thrown in the function wrapped in jQuery(). + + + +

    This method is fired when an error is thrown synchronously in a function wrapped in jQuery() or jQuery( document ).ready(), or equivalent. By default it re-throws the error in a timeout so that it's logged in the console and passed to window.onerror instead of being swallowed. Overwrite this method if you want to handle such errors differently.

    +
    + + Pass the received error to console.error. + + + + +
    diff --git a/entries/jQuery.removeData.xml b/entries/jQuery.removeData.xml index 8a85933b..6a92a25f 100644 --- a/entries/jQuery.removeData.xml +++ b/entries/jQuery.removeData.xml @@ -1,5 +1,5 @@ - + jQuery.removeData() 1.2.3 @@ -19,13 +19,13 @@ Set a data store for 2 names then remove one of them. + + jQuery.speed + Creates an object containing a set of properties ready to be used in the definition of custom animations. + + 1.0 + + + + A string indicating which easing function to use for the transition. + + + A function to call once the animation is complete. + + + + + 1.1 + + + + + + 1.1 + + + A string or number determining how long the animation will run. + + + + + A string indicating which easing function to use for the transition. + + + A function to call once the animation is complete. + + + + +

    The $.speed() method provides a way to define properties, such as duration, easing, and queue, to use in a custom animation. By using it, you don't have to implement the logic that deals with default values and optional parameters.

    +

    This method is meant for plugin developers who are creating new animation methods. Letting $.speed() do all the parameter hockey and normalization for you, rather than duplicating the logic yourself, makes your work simpler. An example of use can be found in the animated form of .addClass() of jQuery UI.

    +
    + + + +
    diff --git a/entries/jQuery.sub.xml b/entries/jQuery.sub.xml index a52c9ab6..04cdfdb8 100644 --- a/entries/jQuery.sub.xml +++ b/entries/jQuery.sub.xml @@ -6,9 +6,9 @@
    Creates a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object. -

    - This method is deprecated as of jQuery 1.7 and will be moved to a plugin in jQuery 1.8. -

    +
    +

    Note: This API has been removed in jQuery 1.9.

    +

    There are two specific use cases for which jQuery.sub() was created. The first was for providing a painless way of overriding jQuery methods without completely destroying the original methods and another was for helping to do encapsulation and basic namespacing for jQuery plugins.

    Note that jQuery.sub() doesn't attempt to do any sort of isolation - that's not its intention. All the methods on the sub'd version of jQuery will still point to the original jQuery (events bound and triggered will still be through the main jQuery, data will be bound to elements through the main jQuery, Ajax queries and events will run through the main jQuery, etc.).

    Note that if you're looking to use this for plugin development you should first strongly consider using something like the jQuery UI widget factory which manages both state and plugin sub-methods. Some examples of using the jQuery UI widget factory to build a plugin.

    @@ -47,7 +47,7 @@ typeof jQuery( "body" ).myCustomMethod // undefined }; myjQuery(function( $ ) { - $( ".menu" ).click(function() { + $( ".menu" ).on( "click", function() { $( this ).find( ".submenu" ).remove(); }); diff --git a/entries/jQuery.support.xml b/entries/jQuery.support.xml index c44b2b42..3252fd6e 100644 --- a/entries/jQuery.support.xml +++ b/entries/jQuery.support.xml @@ -4,10 +4,15 @@ 1.3 - A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support. + A collection of properties that represent the presence of different browser features or bugs; intended for jQuery's internal use. + +

    A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support.

    +

    As of jQuery 1.11 or 1.12, jQuery.support is no longer JSON-serializable; some properties point to functions that return the support test result when called. This was necessary to support lazy execution of support tests.

    +
    +
    diff --git a/entries/jQuery.trim.xml b/entries/jQuery.trim.xml index d0dcfa68..cfc537b6 100644 --- a/entries/jQuery.trim.xml +++ b/entries/jQuery.trim.xml @@ -1,5 +1,5 @@ - + jQuery.trim() 1.0 @@ -9,6 +9,9 @@ Remove the whitespace from the beginning and end of a string. +
    +

    Note: This API has been deprecated in jQuery 3.5; please use the native String.prototype.trim method instead. Unlike jQuery.trim, String.prototype.trim does not work with types other than strings (null, undefined, Number). Make sure that your code is compatible when migrating.

    +

    The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string. If these whitespace characters occur in the middle of the string, they are preserved.

    @@ -34,4 +37,5 @@ $.trim(" hello, how are you? "); +
    diff --git a/entries/jQuery.type.xml b/entries/jQuery.type.xml index f77b3139..4dd56897 100644 --- a/entries/jQuery.type.xml +++ b/entries/jQuery.type.xml @@ -1,5 +1,5 @@ - + jQuery.type() 1.4.3 @@ -9,6 +9,9 @@ Determine the internal JavaScript [[Class]] of an object. +
    +

    Note: This API has been deprecated in jQuery 3.3.

    +

    A number of techniques are used to determine the exact return value for an object. The [[Class]] is determined as follows:

    • If the object is undefined or null, then "undefined" or "null" is returned accordingly. @@ -24,14 +27,16 @@
    • jQuery.type( true ) === "boolean"
    • jQuery.type( new Boolean() ) === "boolean"
    • jQuery.type( 3 ) === "number"
    • -
    • jQuery.type( new Number(3) ) === "number"
    • +
    • jQuery.type( new Number( 3 ) ) === "number"
    • jQuery.type( "test" ) === "string"
    • -
    • jQuery.type( new String("test") ) === "string"
    • -
    • jQuery.type( function(){} ) === "function"
    • +
    • jQuery.type( new String( "test" ) ) === "string"
    • +
    • jQuery.type( function() {} ) === "function"
    • jQuery.type( [] ) === "array"
    • jQuery.type( new Array() ) === "array"
    • jQuery.type( new Date() ) === "date"
    • jQuery.type( new Error() ) === "error" // as of jQuery 1.9
    • +
    • jQuery.type( Symbol() ) === "symbol" // as of jQuery 1.9
    • +
    • jQuery.type( Object( Symbol() ) ) === "symbol" // as of jQuery 1.12
    • jQuery.type( /test/ ) === "regexp"
    @@ -49,4 +54,5 @@ Is it a RegExp?
    +
    diff --git a/entries/jQuery.unique.xml b/entries/jQuery.unique.xml index 0546cfa7..bac61334 100644 --- a/entries/jQuery.unique.xml +++ b/entries/jQuery.unique.xml @@ -1,5 +1,5 @@ - + jQuery.unique() 1.1.3 @@ -9,6 +9,9 @@ Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. +
    +

    As of jQuery 3.0, this method is deprecated and just an alias of jQuery.uniqueSort(). Please use that method instead.

    +

    The $.unique() function searches through an array of objects, sorting the array, and removing any duplicate nodes. A node is considered a duplicate if it is the exact same node as one already in the array; two different nodes with identical attributes are not considered to be duplicates. This function only works on plain JavaScript arrays of DOM elements, and is chiefly used internally by jQuery. You probably will never need to use it.

    As of jQuery 1.4 the results will always be returned in document order.

    @@ -20,10 +23,10 @@ var divs = $( "div" ).get(); // Add 3 elements of class dup too (they are divs) divs = divs.concat( $( ".dup" ).get() ); -$( "div:eq(1)" ).text( "Pre-unique there are " + divs.length + " elements." ); +$( "div" ).eq( 1 ).text( "Pre-unique there are " + divs.length + " elements." ); divs = jQuery.unique( divs ); -$( "div:eq(2)" ).text( "Post-unique there are " + divs.length + " elements." ) +$( "div" ).eq( 2 ).text( "Post-unique there are " + divs.length + " elements." ) .css( "color", "red" ); ]]>
    +
    diff --git a/entries/jQuery.uniqueSort.xml b/entries/jQuery.uniqueSort.xml new file mode 100644 index 00000000..4cc08664 --- /dev/null +++ b/entries/jQuery.uniqueSort.xml @@ -0,0 +1,46 @@ + + + jQuery.uniqueSort() + + 1.12-and-2.2 + + The Array or an Array-like object of DOM elements. + + + Sorts an array or an array-like object of DOM elements, in place, with the duplicates removed. Note that this only works on arrays/array-likes of DOM elements, not strings or numbers. + +

    The $.uniqueSort() function searches through an array or an array-like object of DOM elements, sorting the array/array-like, and removing any duplicate nodes. A node is considered a duplicate if it is the exact same node as one already in the input; two different nodes with identical attributes are not considered to be duplicates. This function only works on plain JavaScript arrays/array-like objects of DOM elements, and is chiefly used internally by jQuery. You probably will never need to use it.

    +

    Prior to jQuery 3.0, this method was called jQuery.unique().

    +

    As of jQuery 1.4 the results will always be returned in document order.

    +
    + + Removes any duplicate elements from the array of divs. + + + There are 6 divs in this document. +
    +
    +
    +
    +
    +]]> +
    + + +
    diff --git a/entries/jQuery.when.xml b/entries/jQuery.when.xml index 7f053618..a27f2adc 100644 --- a/entries/jQuery.when.xml +++ b/entries/jQuery.when.xml @@ -3,12 +3,16 @@ jQuery.when() 1.5 - - One or more Deferred objects, or plain JavaScript objects. + + Zero or more Thenable objects. + + + - Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + Provides a way to execute callback functions based on zero or more Thenable objects, usually Deferred objects that represent asynchronous events. +

    If no arguments are passed to jQuery.when(), it will return a resolved Promise.

    If a single Deferred is passed to jQuery.when(), its Promise object (a subset of the Deferred methods) is returned by the method. Additional methods of the Promise object can be called to attach callbacks, such as deferred.then. When the Deferred is resolved or rejected, usually by the code that created the Deferred originally, the appropriate callbacks will be called. For example, the jqXHR object returned by jQuery.ajax() is a Promise-compatible object and can be used this way:

    
     $.when( $.ajax( "test.aspx" ) ).then(function( data, textStatus, jqXHR ) {
    @@ -56,10 +60,10 @@ d1.resolve();
     d2.resolve( "abc" );
     d3.resolve( 1, 2, 3, 4, 5 );
         
    -

    In the multiple-Deferreds case where one of the Deferreds is rejected, jQuery.when() immediately fires the failCallbacks for its master Deferred. Note that some of the Deferreds may still be unresolved at that point. The arguments passed to the failCallbacks match the signature of the failCallback for the Deferred that was rejected. If you need to perform additional processing for this case, such as canceling any unfinished ajax requests, you can keep references to the underlying jqXHR objects in a closure and inspect/cancel them in the failCallback.

    +

    In the multiple-Deferreds case where one of the Deferreds is rejected, jQuery.when() immediately fires the failCallbacks for its master Deferred. Note that some of the Deferreds may still be unresolved at that point. The arguments passed to the failCallbacks match the signature of the failCallback for the Deferred that was rejected. If you need to perform additional processing for this case, such as canceling any unfinished Ajax requests, you can keep references to the underlying jqXHR objects in a closure and inspect/cancel them in the failCallback.

    - Execute a function after two ajax requests are successful. (See the jQuery.ajax() documentation for a complete description of success and error cases for an ajax request). + Execute a function after two Ajax requests are successful. (See the jQuery.ajax() documentation for a complete description of success and error cases for an ajax request). - A DOM Element, Document, or jQuery to use as context + + A DOM Element, Document, jQuery or selector to use as context @@ -49,7 +50,7 @@

    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" );
     });
           
    @@ -57,10 +58,11 @@ $( "div.foo" ).click(function() {

    Internally, selector context is implemented with the .find() method, so $( "span", this ) is equivalent to $( this ).find( "span" ).

    Using DOM elements

    -

    The second and third formulations of this function create a jQuery object using one or more DOM elements that were already selected in some other way. When passing an array, each element must be a DOM element; mixed data is not supported. A jQuery object is created from the array elements in the order they appeared in the array; unlike most other multi-element jQuery operations, the elements are not sorted in DOM order.

    +

    The second and third formulations of this function create a jQuery object using one or more DOM elements that were already selected in some other way. A jQuery object is created from the array elements in the order they appeared in the array; unlike most other multi-element jQuery operations, the elements are not sorted in DOM order. Elements will be copied from the array as-is and won't be unwrapped if they're already jQuery collections.

    +

    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();
     });
           
    @@ -76,7 +78,7 @@ $.post( "url.xml", function( data ) {

    When a jQuery object is passed to the $() function, a clone of the object is created. This new jQuery object references the same DOM elements as the initial one.

    Returning an Empty Set

    -

    As of jQuery 1.4, calling the jQuery() method with no arguments returns an empty jQuery set (with a .length property of 0). In previous versions of jQuery, this would return a set containing the document node.

    +

    Calling the jQuery() method with no arguments returns an empty jQuery set (with a .length property of 0). Similarly, if an argument of null, undefined, an empty array ([]), or an empty string ("") is passed, the set contains no elements.

    Working With Plain Objects

    At present, the only operations supported on plain JavaScript objects wrapped in jQuery are: .data(),.prop(),.on(), .off(), .trigger() and .triggerHandler(). The use of .data() (or any method requiring .data()) on a plain object will result in a new property on the object called jQuery{randomNumber} (eg. jQuery123456789).

    
    @@ -154,7 +156,7 @@ $( myForm.elements ).hide();
           
             A string of HTML to create on the fly. Note that this parses HTML, not XML.
           
    -      
    +      
             A document in which the new elements will be created.
           
         
    @@ -174,14 +176,14 @@ $( myForm.elements ).hide();
           
    $( "<p id='test'>My <em>new</em> text</p>" ).appendTo( "body" );

    For explicit parsing of a string to HTML, use the $.parseHTML() method.

    By default, elements are created with an .ownerDocument matching the document into which the jQuery library was loaded. Elements being injected into a different document should be created using that document, e.g., $("<p>hello iframe</p>", $("#myiframe").prop("contentWindow").document).

    -

    If the HTML is more complex than a single tag without attributes, as it is in the above example, the actual creation of the elements is handled by the browser's .innerHTML mechanism. In most cases, jQuery creates a new <div> element and sets the innerHTML property of the element to the HTML snippet that was passed in. When the parameter has a single tag (with optional closing tag or quick-closing) — $( "<img />" ) or $( "<img>" ), $( "<a></a>" ) or $( "<a>" ) — jQuery creates the element using the native JavaScript .createElement() function.

    +

    If the HTML is more complex than a single tag without attributes, as it is in the above example, the actual creation of the elements is handled by the browser's .innerHTML mechanism. In most cases, jQuery creates a new <div> element and sets the innerHTML property of the element to the HTML snippet that was passed in. When the parameter has a single tag (with optional closing tag or quick-closing) — $( "<img />" ) or $( "<img>" ), $( "<a></a>" ) or $( "<a>" ) — jQuery creates the element using the native JavaScript .createElement() function.

    When passing in complex HTML, some browsers may not generate a DOM that exactly replicates the HTML source provided. As mentioned, jQuery uses the browser's .innerHTML property to parse the passed HTML and insert it into the current document. During this process, some browsers filter out certain elements such as <html>, <title>, or <head> elements. As a result, the elements inserted may not be representative of the original string passed.

    -

    Filtering isn't, however, limited to these tags. For example, Internet Explorer prior to version 8 will also convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

    +

    Filtering isn't, however, limited to these tags. For example, Internet Explorer prior to version 8 will also convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

    To ensure cross-platform compatibility, the snippet must be well-formed. Tags that can contain other elements should be paired with a closing tag:

    -
    $( "<a href='http://jquery.com'></a>" );
    +
    $( "<a href='https://jquery.com'></a>" );

    Tags that cannot contain elements may be quick-closed or not:

    
    -$( "<img>" );
    +$( "<img />" );
     $( "<input>" );
           

    When passing HTML to jQuery(), note that text nodes are not treated as DOM elements. With the exception of a few methods (such as .content()), they are generally ignored or removed. E.g:

    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 d18b6011..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,13 +18,11 @@ - - 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.

    -

    The keydown event is sent to an element when the user first presses a key on the keyboard. 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.

    +
    +

    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:

    
     <form>
    @@ -36,19 +34,19 @@
         

    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.

    @@ -58,19 +56,19 @@ $( "#other" ).click(function() { Show the event object for the keydown handler when a key is pressed in the input. - +
    + + + keydown event + Trigger the "keydown" event on an element. + + 1.0 + + The string "keydown". + + + +

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

    +
    + + +
    + +
    diff --git a/entries/keypress-shorthand.xml b/entries/keypress-shorthand.xml new file mode 100644 index 00000000..56a0d1d8 --- /dev/null +++ b/entries/keypress-shorthand.xml @@ -0,0 +1,36 @@ + + + .keypress() + Bind an event handler to the "keypress" 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 .keypress( handler ) or .keypress( eventData, handler ), use .on( "keypress", handler ) or .on( "keypress", eventData, handler ), respectively.

    +

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

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

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

    +

    Note: as the keypress event isn't covered by any official specification, the actual behavior encountered when using it may differ across browsers, browser versions, and platforms.

    -

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

    The keypress event is sent to an element when the browser registers keyboard input. This is similar to the keydown event, except that modifier and non-printing keys such as Shift, Esc, and delete trigger keydown events but not keypress events. Other differences between the two events may arise depending on platform and browser.

    A keypress event handler 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 controls can always get focus so are reasonable candidates for this event type.

    For example, consider the HTML:

    @@ -40,19 +38,19 @@

    The event handler can be bound to the input field:

    
    -$( "#target" ).keypress(function() {
    -  console.log( "Handler for .keypress() called." );
    -});
    +$( "#target" ).on( "keypress", function() {
    +  console.log( "Handler for `keypress` called." );
    +} );
         

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

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

    -

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

    +

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

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

    After this code executes, clicks on the Trigger the handler div will also log 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.

    @@ -60,22 +58,22 @@ $( "#other" ).click(function() {

    Note that keydown and keyup provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, a lowercase "a" will be reported as 65 by keydown and keyup, but as 97 by keypress. An uppercase "A" is reported as 65 by all events. Because of this distinction, when catching special keystrokes such as arrow keys, .keydown() or .keyup() is a better choice.

    - Show the event object when a key is pressed in the input. Note: This demo relies on a simple $.print() plugin (http://api.jquery.com/resources/events.js) for the event object's output. + Show the event object when a key is pressed in the input. Note: This demo relies on a simple $.print() plugin (https://api.jquery.com/resources/events.js) for the event object's output. - + + + + keypress event + Trigger the "keypress" event on an element. + + 1.0 + + The string "keypress". + + + +

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

    +
    + + +
    + + diff --git a/entries/keyup-shorthand.xml b/entries/keyup-shorthand.xml new file mode 100644 index 00000000..965dbeb8 --- /dev/null +++ b/entries/keyup-shorthand.xml @@ -0,0 +1,36 @@ + + + .keyup() + Bind an event handler to the "keyup" 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 .keyup( handler ) or .keyup( eventData, handler ), use .on( "keyup", handler ) or .on( "keyup", eventData, handler ), respectively.

    +

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

    +
    +
    + + + + +
    diff --git a/entries/keyup.xml b/entries/keyup.xml index 2d523041..b0d6399f 100644 --- a/entries/keyup.xml +++ b/entries/keyup.xml @@ -1,16 +1,15 @@ - - .keyup() - Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "keyup" event, or trigger that event on an element. + + + keyup event + Bind an event handler to the "keyup" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "keyup". - - - 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( "keyup", handler ) in the first two variations, and .trigger( "keyup" ) in the third.

    +
    +

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

    +

    The keyup event is sent to an element when the user releases a key on the keyboard. 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,19 +34,19 @@
         

    The event handler can be bound to the input field:

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

    Now when the insertion point is inside the field and a key is pressed and released, the alert is displayed:

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

    -

    To trigger the event manually, apply .keyup() without arguments:

    +

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

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

    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.

    @@ -58,20 +56,20 @@ $( "#other" ).click(function() { Show the event object for the keyup handler (using a simple $.print plugin) when a key is released in the input. - +
    + + + keyup event + Trigger the "keyup" event on an element. + + 1.0 + + The string "keyup". + + + +

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

    +
    + + +
    + +
    diff --git a/entries/lang-selector.xml b/entries/lang-selector.xml index 9ec3b3e4..fedf3c4c 100644 --- a/entries/lang-selector.xml +++ b/entries/lang-selector.xml @@ -12,7 +12,7 @@

    The :lang() selector matches elements that have a language value equal to the supplied language code or that start with the supplied language code immediately followed by "-". For example, the selector $("div:lang(en)")will match <div lang="en"> and <div lang="en-us"> (and any of their descendant <div>s), but not <div lang="fr">

    For HTML elements, the language value is determined by the lang attribute and possibly information from meta elements or HTTP headers.

    -

    Further discussion of this usage can be found in the W3C CSS specification.

    +

    Further discussion of this usage can be found in the W3C CSS specification.

    Color div elements according to their language. diff --git a/entries/last-child-selector.xml b/entries/last-child-selector.xml index 8e5d81e3..06d8e61b 100644 --- a/entries/last-child-selector.xml +++ b/entries/last-child-selector.xml @@ -7,7 +7,7 @@
    Selects all elements that are the last child of their parent. -

    While :last matches only a single element, :last-child can match more than one: one for each parent.

    +

    While .last() matches only a single element, :last-child can match more than one: one for each parent.

    Find the last span in each matched div and add some css plus a hover state. diff --git a/entries/last-selector.xml b/entries/last-selector.xml index 2cbd886f..128eec49 100644 --- a/entries/last-selector.xml +++ b/entries/last-selector.xml @@ -1,5 +1,5 @@ - + :last Selector :last @@ -7,13 +7,16 @@ Selects the last matched element. +
    +

    As of jQuery 3.4, the :last pseudo-class is deprecated. Remove it from your selectors and filter the results later using .last().

    +

    Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.

    Finds the last table row. @@ -26,4 +29,5 @@ $( "tr:last" ).css({ backgroundColor: "yellow", fontWeight: "bolder" }); +
    diff --git a/entries/last.xml b/entries/last.xml index 4f9b59df..73ddafa5 100644 --- a/entries/last.xml +++ b/entries/last.xml @@ -24,17 +24,22 @@ $( "li" ).last().css( "background-color", "red" );

    The result of this call is a red background for the final item.

    - Highlight the last span in a paragraph. + Highlight the last item in a list. Look: This is some text in a paragraph. This is a note about it.

    +
      +
    • Look:
    • +
    • This is some text in a list.
    • +
    • This is a note about it.
    • +
    • This is another note about it.
    • +
    ]]>
    diff --git a/entries/length.xml b/entries/length.xml index 105f23d8..37a2d54c 100644 --- a/entries/length.xml +++ b/entries/length.xml @@ -12,12 +12,12 @@ Count the divs. Click to add more. " ) ); var n = $( "div" ).length; $( "span" ).text( "There are " + n + " divs." + "Click to add more."); - }) + } ) // Trigger the click to start .trigger( "click" ); ]]> diff --git a/entries/live.xml b/entries/live.xml index 049322e2..0943af95 100644 --- a/entries/live.xml +++ b/entries/live.xml @@ -32,7 +32,9 @@ -

    As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

    +
    +

    Note: This API has been removed in jQuery 1.9; please use on() instead.

    +

    This method provides a means to attach delegated event handlers to the document element of a page, which simplifies the use of event handlers when content is dynamically added to a page. See the discussion of direct versus delegated events in the .on() method for more information.

    Rewriting the .live() method in terms of its successors is straightforward; these are templates for equivalent calls for all three event attachment methods:

    
    @@ -102,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 d95f81bc..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.
         
    @@ -20,7 +19,9 @@
         
       
       
    -    

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

    +
    +

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

    +

    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:

    
    @@ -28,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
    • @@ -57,23 +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. 100) { $( this ).addClass( "bigImg" ); } -}); +} ); ]]> - - + + + + + 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/load.xml b/entries/load.xml index 951c43f6..c0f6a46f 100644 --- a/entries/load.xml +++ b/entries/load.xml @@ -18,12 +18,12 @@ A callback function that is executed when the request completes. - Load data from the server and place the returned HTML into the matched element. + Load data from the server and place the returned HTML into the matched elements.
      -

      Note: The event handling suite also has a method named .load(). jQuery determines which method to fire based on the set of arguments passed to it.

      +

      Note: Prior to jQuery 3.0, the event handling suite also had a method named .load(). Older versions of jQuery determined which method to fire based on the set of arguments passed to it.

      -

      This method is the simplest way to fetch data from the server. It is roughly equivalent to $.get(url, data, success) except that it is a method rather than global function and it has an implicit callback function. When a successful response is detected (i.e. when textStatus is "success" or "notmodified"), .load() sets the HTML contents of the matched element to the returned data. This means that most uses of the method can be quite simple:

      +

      This method is the simplest way to fetch data from the server. It is roughly equivalent to $.get(url, data, success) except that it is a method rather than global function and it has an implicit callback function. When a successful response is detected (i.e. when textStatus is "success" or "notmodified"), .load() sets the HTML contents of the matched elements to the returned data. This means that most uses of the method can be quite simple:

      
       $( "#result" ).load( "ajax/test.html" );
           
      diff --git a/entries/lt-selector.xml b/entries/lt-selector.xml index b85b5f77..703c427f 100644 --- a/entries/lt-selector.xml +++ b/entries/lt-selector.xml @@ -1,5 +1,5 @@ - + :lt() Selector :lt(index) @@ -17,6 +17,9 @@ Select all elements at an index less than index within the matched set. +
      +

      As of jQuery 3.4, the :lt pseudo-class is deprecated. Remove it from your selectors and filter the results later using .slice(). For example, :lt(3) can be replaced with a call to .slice( 0, 3 ).

      +

      index-related selectors

      @@ -42,4 +45,5 @@ $( "td:lt(-2)" ).css( "color", "red" ); +
      diff --git a/entries/map.xml b/entries/map.xml index 55a87d83..101fa001 100644 --- a/entries/map.xml +++ b/entries/map.xml @@ -69,7 +69,7 @@ $( "p" )
      - +
      ]]> @@ -135,9 +135,9 @@ $.fn.equalizeHeights = function() { return this.height( Math.max.apply( this, maxHeight ) ); }; -$( "input" ).click(function() { +$( "input" ).on( "click", function() { $( "div" ).equalizeHeights(); -}); +} ); ]]>
      + + .mousedown() + Bind an event handler to the "mousedown" 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 .mousedown( handler ) or .mousedown( eventData, handler ), use .on( "mousedown", handler ) or .on( "mousedown", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mousedown.xml b/entries/mousedown.xml index 98f03d33..5ce0e273 100644 --- a/entries/mousedown.xml +++ b/entries/mousedown.xml @@ -1,16 +1,15 @@ - - .mousedown() - Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "mousedown" event, or trigger that event on an element. + + + mousedown event + Bind an event handler to the "mousedown" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mousedown". - - - 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( "mousedown", handler) in the first variation, and .trigger( "mousedown" ) in the second.

      +
      +

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

      +

      The mousedown event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed. Any HTML element can receive this event.

      For example, consider the HTML:

      <div id="target">
      @@ -33,27 +31,28 @@
         Trigger the handler
       </div>
           
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any <div>:

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

      Now if we click on this element, the alert is displayed:

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

      We can also trigger the event when a different element is clicked:

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

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

      -

      The mousedown event is sent when any mouse button is clicked. To act only on specific buttons, we can use the event object's which property. Not all browsers support this property (Internet Explorer uses button instead), but jQuery normalizes the property so that it is safe to use in any browser. The value of which will be 1 for the left button, 2 for the middle button, or 3 for the right button.

      +

      The mousedown event is sent when any mouse button is clicked. To act only on specific buttons, we can use the event object's which property. Not all browsers support this property (Internet Explorer uses button instead), but jQuery normalizes the property so that it is safe to use in any browser. The value of which will be 1 for the left button, 2 for the middle button, or 3 for the right button.

      This event is primarily useful for ensuring that the primary button was used to begin a drag operation; if ignored, strange results can occur when the user attempts to use a context menu. While the middle and right buttons can be detected with these properties, this is not reliable. In Opera and Safari, for example, right mouse button clicks are not detectable by default.

      If the user clicks on an element, drags away from it, and releases the button, this is still counted as a mousedown event. This sequence of actions is treated as a "canceling" of the button press in most user interfaces, so it is usually better to use the click event unless we know that the mousedown event is preferable for a particular situation.

      @@ -61,12 +60,12 @@ $( "#other" ).click(function() { Show texts when mouseup and mousedown event triggering. Mouse up." ); - }) - .mousedown(function() { + } ) + .on( "mousedown", function() { $( this ).append( "Mouse down." ); - }); + } ); ]]> Press mouse and release here.

      @@ -74,5 +73,23 @@ $( "p" ) - + +
      + + + mousedown event + Trigger the "mousedown" event on an element. + + 1.0 + + The string "mousedown". + + + +

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

      +
      + +
      + +
      diff --git a/entries/mouseenter-shorthand.xml b/entries/mouseenter-shorthand.xml new file mode 100644 index 00000000..49b2285a --- /dev/null +++ b/entries/mouseenter-shorthand.xml @@ -0,0 +1,36 @@ + + + .mouseenter() + Bind an event handler to the "mouseenter" 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 .mouseenter( handler ) or .mouseenter( eventData, handler ), use .on( "mouseenter", handler ) or .on( "mouseenter", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mouseenter.xml b/entries/mouseenter.xml index ae59e888..d2232926 100644 --- a/entries/mouseenter.xml +++ b/entries/mouseenter.xml @@ -1,16 +1,15 @@ - - .mouseenter() - Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. + +Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. + + + mouseenter event + Bind an event handler to be fired when the mouse enters an element. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mouseenter". - - - 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( "mouseenter", handler ) in the first two variations, and .trigger( "mouseenter" ) in the third.

      +
      +

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

      +

      The mouseenter JavaScript event is proprietary to Internet Explorer. Because of the event's general utility, jQuery simulates this event so that it can be used regardless of browser. This event is sent to an element when the mouse pointer enters the element. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -37,20 +35,21 @@
         Trigger the handler
       </div>
       <div id="log"></div>
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any element:

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

      Now when the mouse pointer moves over the Outer <div>, the message is appended to <div id="log">. You can also trigger the event when another element is clicked:

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

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

      The mouseenter event differs from mouseover in the way it handles event bubbling. If mouseover were used in this example, then when the mouse pointer moved over the Inner element, the handler would be triggered. This is usually undesirable behavior. The mouseenter event, on the other hand, only triggers its handler when the mouse enters the element it is bound to, not a descendant. So in this example, the handler is triggered when the mouse enters the Outer element, but not the Inner element.

      @@ -81,23 +80,23 @@ $( "#other" ).click(function() { @@ -115,5 +114,23 @@ $( "div.enterleave" ) - +
      + + + mouseenter event + Trigger the "mouseenter" event on an element. + + 1.0 + + The string "mouseenter". + + + +

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

      +
      + + +
      + +
      diff --git a/entries/mouseleave-shorthand.xml b/entries/mouseleave-shorthand.xml new file mode 100644 index 00000000..9ff235eb --- /dev/null +++ b/entries/mouseleave-shorthand.xml @@ -0,0 +1,36 @@ + + + .mouseleave() + Bind an event handler to the "mouseleave" 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 .mouseleave( handler ) or .mouseleave( eventData, handler ), use .on( "mouseleave", handler ) or .on( "mouseleave", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mouseleave.xml b/entries/mouseleave.xml index 25ed2dc7..98c1ff97 100644 --- a/entries/mouseleave.xml +++ b/entries/mouseleave.xml @@ -1,16 +1,15 @@ - - .mouseleave() - Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. + +Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. + + + mouseleave event + Bind an event handler to be fired when the mouse leaves an element. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mouseleave". - - - 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('mouseleave', handler) in the first two variations, and .trigger('mouseleave') in the third.

      +
      +

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

      +

      The mouseleave JavaScript event is proprietary to Internet Explorer. Because of the event's general utility, jQuery simulates this event so that it can be used regardless of browser. This event is sent to an element when the mouse pointer leaves the element. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -37,20 +35,21 @@
         Trigger the handler
       </div>
       <div id="log"></div>
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any element:

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

      Now when the mouse pointer moves out of the Outer <div>, the message is appended to <div id="log">. You can also trigger the event when another element is clicked:

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

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

      The mouseleave event differs from mouseout in the way it handles event bubbling. If mouseout were used in this example, then when the mouse pointer moved out of the Inner element, the handler would be triggered. This is usually undesirable behavior. The mouseleave event, on the other hand, only triggers its handler when the mouse leaves the element it is bound to, not a descendant. So in this example, the handler is triggered when the mouse leaves the Outer element, but not the Inner element.

      @@ -80,23 +79,23 @@ $( "#other" ).click(function() { @@ -113,5 +112,23 @@ $( "div.enterleave" ) - +
      + + + mouseleave event + Trigger the "mouseleave" event on an element. + + 1.0 + + The string "mouseleave". + + + +

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

      +
      + + +
      + +
      diff --git a/entries/mousemove-shorthand.xml b/entries/mousemove-shorthand.xml new file mode 100644 index 00000000..7b5e5c31 --- /dev/null +++ b/entries/mousemove-shorthand.xml @@ -0,0 +1,36 @@ + + + .mousemove() + Bind an event handler to the "mousemove" 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 .mousemove( handler ) or .mousemove( eventData, handler ), use .on( "mousemove", handler ) or .on( "mousemove", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mousemove.xml b/entries/mousemove.xml index 240f92c3..5aaeef0b 100644 --- a/entries/mousemove.xml +++ b/entries/mousemove.xml @@ -1,16 +1,15 @@ - - .mousemove() - Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "mousemove" event, or trigger that event on an element. + + + mousemove event + Bind an event handler to the "mousemove" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mousemove". - - - 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( "mousemove", handler ) in the first two variations, and .trigger( "mousemove" ) in the third.

      +
      +

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

      +

      The mousemove event is sent to an element when the mouse pointer moves inside the element. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -37,46 +35,46 @@
           

      The event handler can be bound to the target:

      
      -$( "#target" ).mousemove(function( event ) {
      -  var msg = "Handler for .mousemove() called at ";
      +$( "#target" ).on( "mousemove", function( event ) {
      +  var msg = "Handler for `mousemove` called at ";
         msg += event.pageX + ", " + event.pageY;
         $( "#log" ).append( "<div>" + msg + "</div>" );
      -});
      +} );
           

      Now when the mouse pointer moves within the target button, the messages are appended to <div id="log">:

      - Handler for .mousemove() called at (399, 48) + Handler for `mousemove` called at (399, 48)
      - Handler for .mousemove() called at (398, 46) + Handler for `mousemove` called at (398, 46)
      - Handler for .mousemove() called at (397, 44) + Handler for `mousemove` called at (397, 44)
      - Handler for .mousemove() called at (396, 42) + Handler for `mousemove` called at (396, 42)

      -

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

      +

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

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

      After this code executes, clicks on the Trigger button will also append the message:

      - Handler for .mousemove() called at (undefined, undefined) + Handler for `mousemove` called at (undefined, undefined)

      When tracking mouse movement, you usually need to know the actual position of the mouse pointer. The event object that is passed to the handler contains some information about the mouse coordinates. Properties such as .clientX, .offsetX, and .pageX are available, but support for them differs between browsers. Fortunately, jQuery normalizes the .pageX and .pageY properties so that they can be used in all browsers. These properties provide the X and Y coordinates of the mouse pointer relative to the top-left corner of the document, as illustrated in the example output above.

      Keep in mind that the mousemove event is triggered whenever the mouse pointer moves, even for a pixel. This means that hundreds of events can be generated over a very small amount of time. If the handler has to do any significant processing, or if multiple handlers for the event exist, this can be a serious performance drain on the browser. It is important, therefore, to optimize mousemove handlers as much as possible, and to unbind them as soon as they are no longer needed.

      -

      A common pattern is to bind the mousemove handler from within a mousedown hander, and to unbind it from a corresponding mouseup handler. If implementing this sequence of events, remember that the mouseup event might be sent to a different HTML element than the mousemove event was. To account for this, the mouseup handler should typically be bound to an element high up in the DOM tree, such as <body>.

      +

      A common pattern is to bind the mousemove handler from within a mousedown handler, and to unbind it from a corresponding mouseup handler. If implementing this sequence of events, remember that the mouseup event might be sent to a different HTML element than the mousemove event was. To account for this, the mouseup handler should typically be bound to an element high up in the DOM tree, such as <body>.

      Show the mouse coordinates when the mouse is moved over the yellow div. Coordinates are relative to the window, which in this case is the iframe. 300 - + +
      + + + mousemove event + Trigger the "mousemove" event on an element. + + 1.0 + + The string "mousemove". + + + +

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

      +
      + +
      + +
      diff --git a/entries/mouseout-shorthand.xml b/entries/mouseout-shorthand.xml new file mode 100644 index 00000000..25761ce4 --- /dev/null +++ b/entries/mouseout-shorthand.xml @@ -0,0 +1,36 @@ + + + .mouseout() + Bind an event handler to the "mouseout" 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 .mouseout( handler ) or .mouseout( eventData, handler ), use .on( "mouseout", handler ) or .on( "mouseout", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mouseout.xml b/entries/mouseout.xml index 664e2164..3b014828 100644 --- a/entries/mouseout.xml +++ b/entries/mouseout.xml @@ -1,16 +1,15 @@ - - .mouseout() - Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "mouseout" event, or trigger that event on an element. + + + mouseout event + Bind an event handler to the "mouseout" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mouseout". - - - 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( "mouseout", handler ) in the first two variation, and .trigger( "mouseout" ) in the third.

      +
      +

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

      +

      The mouseout event is sent to an element when the mouse pointer leaves the element. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -38,20 +36,21 @@
       </div>
       <div id="log"></div>
           
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any element:

      
      -$( "#outer" ).mouseout(function() {
      -  $( "#log" ).append( "Handler for .mouseout() called." );
      -});
      +$( "#outer" ).on( "mouseout", function() {
      +  $( "#log" ).append( "Handler for `mouseout` called." );
      +} );
           
      -

      Now when the mouse pointer moves out of the Outer <div>, the message is appended to <div id="log">. To trigger the event manually, apply .mouseout() without an argument::

      +

      Now when the mouse pointer moves out of the Outer <div>, the message is appended to <div id="log">. To trigger the event manually, use .trigger( "mouseout" ):

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

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

      This event type can cause many headaches due to event bubbling. For instance, when the mouse pointer moves out of the Inner element in this example, a mouseout event will be sent to that, then trickle up to Outer. This can trigger the bound mouseout handler at inopportune times. See the discussion for .mouseleave() for a useful alternative.

      @@ -82,23 +81,23 @@ $( "#other" ).click(function() { @@ -116,5 +115,23 @@ $( "div.enterleave" ) - +
      + + + mouseout event + Trigger the "mouseout" event on an element. + + 1.0 + + The string "mouseout". + + + +

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

      +
      + + +
      + +
      diff --git a/entries/mouseover-shorthand.xml b/entries/mouseover-shorthand.xml new file mode 100644 index 00000000..25bc4c01 --- /dev/null +++ b/entries/mouseover-shorthand.xml @@ -0,0 +1,36 @@ + + + .mouseover() + Bind an event handler to the "mouseover" 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 .mouseover( handler ) or .mouseover( eventData, handler ), use .on( "mouseover", handler ) or .on( "mouseover", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mouseover.xml b/entries/mouseover.xml index d8e8b0b0..6897db06 100644 --- a/entries/mouseover.xml +++ b/entries/mouseover.xml @@ -1,16 +1,15 @@ - - .mouseover() - Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "mouseover" event, or trigger that event on an element. + + + mouseover event + Bind an event handler to the "mouseover" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mouseover". - - - 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( "mouseover", handler ) in the first two variations, and .trigger( "mouseover" ) in the third.

      +
      +

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

      +

      The mouseover event is sent to an element when the mouse pointer enters the element. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -38,20 +36,21 @@
       </div>
       <div id="log"></div>
           
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any element:

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

      Now when the mouse pointer moves over the Outer <div>, the message is appended to <div id="log">. We can also trigger the event when another element is clicked:

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

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

      This event type can cause many headaches due to event bubbling. For instance, when the mouse pointer moves over the Inner element in this example, a mouseover event will be sent to that, then trickle up to Outer. This can trigger our bound mouseover handler at inopportune times. See the discussion for .mouseenter() for a useful alternative.

      @@ -82,23 +81,23 @@ $( "#other" ).click(function() { @@ -116,5 +115,23 @@ $( "div.enterleave" ) - + +
      + + + mouseover event + Trigger the "mouseover" event on an element. + + 1.0 + + The string "mouseover". + + + +

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

      +
      + +
      + +
      diff --git a/entries/mouseup-shorthand.xml b/entries/mouseup-shorthand.xml new file mode 100644 index 00000000..edbf836c --- /dev/null +++ b/entries/mouseup-shorthand.xml @@ -0,0 +1,36 @@ + + + .mouseup() + Bind an event handler to the "mouseup" 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 .mouseup( handler ) or .mouseup( eventData, handler ), use .on( "mouseup", handler ) or .on( "mouseup", eventData, handler ), respectively.

      +

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

      +
      +
      + + + + +
      diff --git a/entries/mouseup.xml b/entries/mouseup.xml index 80d0f619..205c0794 100644 --- a/entries/mouseup.xml +++ b/entries/mouseup.xml @@ -1,16 +1,15 @@ - - .mouseup() - Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "mouseup" event, or trigger that event on an element. + + + mouseup event + Bind an event handler to the "mouseup" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "mouseup". - - - 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('mouseup', handler) in the first variation, and .trigger('mouseup') in the second.

      +
      +

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

      +

      The mouseup event is sent to an element when the mouse pointer is over the element, and the mouse button is released. Any HTML element can receive this event.

      For example, consider the HTML:

      
      @@ -34,24 +32,25 @@
         Trigger the handler
       </div>
       
      -

      +

      -

      +
      Figure 1 - Illustration of the rendered HTML
      +

      The event handler can be bound to any <div>:

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

      Now if we click on this element, the alert is displayed:

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

      We can also trigger the event when a different element is clicked:

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

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

      If the user clicks outside an element, drags onto it, and releases the button, this is still counted as a mouseup event. This sequence of actions is not treated as a button press in most user interfaces, so it is usually better to use the click event unless we know that the mouseup event is preferable for a particular situation.

      @@ -60,12 +59,12 @@ $( "#other" ).click(function() { Show texts when mouseup and mousedown event triggering. Mouse up." ); - }) - .mousedown(function() { + } ) + .on( "mousedown", function() { $( this ).append( "Mouse down." ); - }); + } ); ]]> Press mouse and release here.

      @@ -73,5 +72,23 @@ $( "p" ) - + +
      + + + mouseup event + Trigger the "mouseup" event on an element. + + 1.0 + + The string "mouseup". + + + +

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

      +
      + +
      + +
      diff --git a/entries/next-adjacent-Selector.xml b/entries/next-adjacent-selector.xml similarity index 100% rename from entries/next-adjacent-Selector.xml rename to entries/next-adjacent-selector.xml diff --git a/entries/nextAll.xml b/entries/nextAll.xml index 8965aab6..e6022093 100644 --- a/entries/nextAll.xml +++ b/entries/nextAll.xml @@ -30,7 +30,7 @@ $( "li.third-item" ).nextAll().css( "background-color", "red" ); Locate all the divs after the first and give them a class.

    We can apply this method to the set of list items:

    
    -$( "li" ).not( ":even" ).css( "background-color", "red" );
    +$( "li" ).not( ":nth-child(2n)" ).css( "background-color", "red" );
         
    -

    The result of this call is a red background for items 2 and 4, as they do not match the selector (recall that :even and :odd use 0-based indexing).

    +

    The result of this call is a red background for items 1, 3 and 5, as they do not match the selector.

    Removing Specific Elements

    The second version of the .not() method allows us to remove elements from the matched set, assuming we have found those elements previously by some other means. For example, suppose our list had an id applied to one of its items:

    
    @@ -61,6 +61,7 @@ $( "li" ).not( document.getElementById( "notli" ) )
         

    This statement changes the color of items 1, 2, 4, and 5. We could have accomplished the same thing with a simpler jQuery expression, but this technique can be useful when, for example, other libraries provide references to plain DOM nodes.

    As of jQuery 1.4, the .not() method can take a function as its argument in the same way that .filter() does. Elements for which the function returns true are excluded from the filtered set; all other elements are included.

    +

    Note: When a CSS selector string is passed to .not(), text and comment nodes will always be removed from the resulting jQuery object during the filtering process. When a specific node or array of nodes are provided, text or comment nodes will only be removed from the jQuery object if they match one of the nodes in the filtering array.

    Adds a border to divs that are not green or blue. diff --git a/entries/nth-child-selector.xml b/entries/nth-child-selector.xml index 40d46787..8a5efc4c 100644 --- a/entries/nth-child-selector.xml +++ b/entries/nth-child-selector.xml @@ -10,9 +10,9 @@ Selects all elements that are the nth-child of their parent. -

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing two <li>s, $( "li:nth-child(1)" ) selects the first <li> while $( "li:eq(1)" ) selects the second.

    -

    The :nth-child(n) pseudo-class is easily confused with :eq(n), even though the two can result in dramatically different matched elements. With :nth-child(n), all children are counted, regardless of what they are, and the specified element is selected only if it matches the selector attached to the pseudo-class. With :eq(n) only the selector attached to the pseudo-class is counted, not limited to children of any other element, and the (n+1)th one (n is 0-based) is selected.

    -

    Further discussion of this unusual usage can be found in the W3C CSS specification.

    +

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. jQuery methods like .first() or .eq() jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing two <li>s, $( "li:nth-child(1)" ) selects the first <li> while $( "li" ).eq( 1 ) selects the second.

    +

    The :nth-child(n) pseudo-class is easily confused with the .eq( n ) call, even though the two can result in dramatically different matched elements. With :nth-child(n), all children are counted, regardless of what they are, and the specified element is selected only if it matches the selector attached to the pseudo-class. With the .eq( n ) call only the selector attached to the pseudo-class is counted, not limited to children of any other element, and the (n+1)th one (n is 0-based) is selected.

    +

    Further discussion of this unusual usage can be found in the W3C CSS specification.

    Find the second li in each matched ul and note it. @@ -51,12 +51,17 @@ $( "ul li:nth-child(2)" ).append( " - 2nd!" ); ]]> - This is a playground to see how the selector works with different strings. Notice that this is different from the :even and :odd which have no regard for parent and just filter the list of elements to every other one. The :nth-child, however, counts the index of the child to its particular parent. In any case, it's easier to see than explain so... + This is a playground to see how the selector works with different strings. Notice that this is different from the even and odd which have no regard for parent and just filter the list of elements to every other one. The :nth-child, however, counts the index of the child to its particular parent. In any case, it's easier to see than explain so... @@ -94,8 +99,8 @@ $( "button" ).click(function() {
    - - + +
    diff --git a/entries/nth-last-child-selector.xml b/entries/nth-last-child-selector.xml index ce21de1f..def39a3b 100644 --- a/entries/nth-last-child-selector.xml +++ b/entries/nth-last-child-selector.xml @@ -10,8 +10,8 @@ Selects all elements that are the nth-child of their parent, counting from the last element to the first. -

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing three <li>s, $( "li:nth-last-child(1)" ) selects the third, last, <li>.

    -

    Further discussion of this usage can be found in the W3C CSS specification.

    +

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as .first() or .eq() jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing three <li>s, $( "li:nth-last-child(1)" ) selects the third, last, <li>.

    +

    Further discussion of this usage can be found in the W3C CSS specification.

    Find the second to last li in each matched ul and note it. @@ -51,7 +51,7 @@ $( "ul li:nth-last-child(2)" ).append( " - 2nd to last!" ); This is a playground to see how the selector works with different strings. Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first. -

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing three <li>s, $('li:nth-last-of-type(1)') selects the third, last, <li>.

    -

    Further discussion of this usage can be found in the W3C CSS specification.

    +

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as .first() or .eq() jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing three <li>s, $('li:nth-last-of-type(1)') selects the third, last, <li>.

    +

    Further discussion of this usage can be found in the W3C CSS specification.

    Find the second to last li in each matched ul and note it. @@ -52,7 +52,7 @@ $( "ul li:nth-last-of-type(2)" ).append( " - 2nd to last!" ); This is a playground to see how the selector works with different strings. Selects all elements that are the nth child of their parent in relation to siblings with the same element name. -

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript's "0-indexed" counting.

    -

    Further discussion of this usage can be found in the W3C CSS specification.

    +

    Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as .first() or .eq() jQuery follows JavaScript's "0-indexed" counting.

    +

    Further discussion of this usage can be found in the W3C CSS specification.

    Find each span that is second in relation to its sibling spans. diff --git a/entries/odd-selector.xml b/entries/odd-selector.xml index 12a75cb8..8b907e15 100644 --- a/entries/odd-selector.xml +++ b/entries/odd-selector.xml @@ -1,12 +1,15 @@ - + :odd Selector :odd 1.0 - Selects odd elements, zero-indexed. See also even. + Selects odd elements, zero-indexed. See also :even. +
    +

    As of jQuery 3.4, the :odd pseudo-class is deprecated. Remove it from your selectors and filter the results later using .odd() (available in jQuery 3.5.0 or newer).

    +

    In particular, note that the 0-based indexing means that, counter-intuitively, :odd selects the second element, fourth element, and so on within the matched set.

    @@ -33,4 +36,5 @@ $( "tr:odd" ).css( "background-color", "#bbbbff" ); +
    diff --git a/entries/odd.xml b/entries/odd.xml new file mode 100644 index 00000000..52fe3baf --- /dev/null +++ b/entries/odd.xml @@ -0,0 +1,47 @@ + + + .odd() + + 3.5 + + Reduce the set of matched elements to the odd ones in the set, numbered from zero. + +

    Given a jQuery object that represents a set of DOM elements, the .odd() method constructs a new jQuery object from the odd elements in that set. Counting starts from zero!

    +

    Consider a page with a simple list on it:

    +
    
    +<ul>
    +  <li>list item 1</li>
    +  <li>list item 2</li>
    +  <li>list item 3</li>
    +  <li>list item 4</li>
    +  <li>list item 5</li>
    +</ul>
    +    
    +

    We can apply this method to the set of list items:

    +
    
    +$( "li" ).odd().css( "background-color", "red" );
    +    
    +

    The result of this call is a red background for the second & 4th items.

    +
    + + Highlight the odd items in a list. + + + +
  • Look:
  • +
  • This is some text in a list.
  • +
  • This is a note about it.
  • +
  • This is another note about it.
  • + +]]> +
    + + +
    diff --git a/entries/off.xml b/entries/off.xml index 2c711a68..fba3925c 100644 --- a/entries/off.xml +++ b/entries/off.xml @@ -46,13 +46,13 @@ function flash() { $( "div" ).show().fadeOut( "slow" ); } -$( "#bind" ).click(function() { +$( "#bind" ).on( "click", function() { $( "body" ) .on( "click", "#theone", flash ) .find( "#theone" ) .text( "Can Click!" ); }); -$( "#unbind" ).click(function() { +$( "#unbind" ).on( "click", function() { $( "body" ) .off( "click", "#theone", flash ) .find( "#theone" ) diff --git a/entries/offset.xml b/entries/offset.xml index 9b1a0093..81923287 100644 --- a/entries/offset.xml +++ b/entries/offset.xml @@ -8,18 +8,18 @@ Get the current coordinates of the first element in the set of matched elements, relative to the document. -

    The .offset() method allows us to retrieve the current position of an element relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.

    +

    The .offset() method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.

    .offset() returns an object containing the properties top and left.

    -

    Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.

    +

    Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for margins set on the <html> document element.

    While it is possible to get the coordinates of elements with visibility:hidden set, display:none is excluded from the rendering tree and thus has a position that is undefined.

    - + Access the offset of the second paragraph: @@ -35,7 +35,7 @@ p.html( "left: " + offset.left + ", top: " + offset.top ); Click to see the offset. - + A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties. Set the current coordinates of every element in the set of matched elements, relative to the document. -

    The .offset() setter method allows us to reposition an element. The element's position is specified relative to the document. If the element's position style property is currently static, it will be set to relative to allow for this repositioning.

    +

    The .offset() setter method allows us to reposition an element. The element's border-box position is specified relative to the document. If the element's position style property is currently static, it will be set to relative to allow for this repositioning.

    Set the offset of the second paragraph: +
    diff --git a/entries/on.xml b/entries/on.xml index 9a7e66ed..c874c4b6 100644 --- a/entries/on.xml +++ b/entries/on.xml @@ -34,16 +34,16 @@

    The .on() method attaches event handlers to the currently selected set of elements in the jQuery object. As of jQuery 1.7, the .on() method provides all functionality required for attaching event handlers. For help in converting from older jQuery event methods, see .bind(), .delegate(), and .live(). To remove events bound with .on(), see .off(). To attach an event that runs only once and then removes itself, see .one()

    Event names and namespaces

    -

    Any event names can be used for the events argument. jQuery will pass through the browser's standard JavaScript event types, calling the handler function when the browser generates events due to user actions such as click. In addition, the .trigger() method can trigger both standard browser event names and custom event names to call attached handlers. Event names should only contain alphanumerics, underscore, and colon chraracters.

    -

    An event name can be qualified by event namespaces that simplify removing or triggering the event. For example, "click.myPlugin.simple" defines both the myPlugin and simple namespaces for this particular click event. A click event handler attached via that string could be removed with .off("click.myPlugin") or .off("click.simple") without disturbing other click handlers attached to the elements. Namespaces are similar to CSS classes in that they are not hierarchical; only one name needs to match. Namespaces beginning with an underscore are reserved for jQuery's use.

    +

    Any event names can be used for the events argument. jQuery will pass through the browser's standard JavaScript event types, calling the handler function when the browser generates events due to user actions such as click. In addition, the .trigger() method can trigger both standard browser event names and custom event names to call attached handlers. Event names should only contain alphanumerics, underscore, and colon characters.

    +

    An event name can be qualified by event namespaces that simplify removing or triggering the event. For example, "click.myPlugin.simple" defines both the myPlugin and simple namespaces for this particular click event. A click event handler attached via that string could be removed with .off("click.myPlugin") or .off("click.simple") without disturbing other click handlers attached to the elements. Namespaces are similar to CSS classes in that they are not hierarchical; only one name needs to match. Namespaces should contain upper/lowercase letters and digits only.

    In the second form of .on(), the events argument is a plain object. The keys are strings in the same form as the events argument with space-separated event type names and optional namespaces. The value for each key is a function (or false value) that is used as the handler instead of the final argument to the method. In other respects, the two forms are identical in their behavior as described below.

    -

    Direct and delegated events

    +

    Direct and delegated event handlers

    The majority of browser events bubble, or propagate, from the deepest, innermost element (the event target) in the document where they occur all the way up to the body and the document element. In Internet Explorer 8 and lower, a few events such as change and submit do not natively bubble but jQuery patches these to bubble and create consistent cross-browser behavior.

    If selector is omitted or is null, the event handler is referred to as direct or directly-bound. The handler is called every time an event occurs on the selected elements, whether it occurs directly on the element or bubbles from a descendant (inner) element.

    When a selector is provided, the event handler is referred to as delegated. The handler is not called when the event occurs directly on the bound element, but only for descendants (inner elements) that match the selector. jQuery bubbles the event from the event target up to the element where the handler is attached (i.e., innermost to outermost element) and runs the handler for any elements along that path matching the selector.

    -

    Event handlers are bound only to the currently selected elements; they must exist at the time your code makes the call to .on(). To ensure the elements are present and can be selected, place scripts after the elements in the HTML markup or perform event binding inside a document ready handler. Alternatively, use delegated events to attach event handlers.

    -

    Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.

    -

    In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated events is their potential for much lower overhead when many elements must be monitored. On a data table with 1,000 rows in its tbody, this example attaches a handler to 1,000 elements:

    +

    Event handlers are bound only to the currently selected elements; they must exist at the time your code makes the call to .on(). To ensure the elements are present and can be selected, place scripts after the elements in the HTML markup or perform event binding inside a document ready handler. Alternatively, use delegated event handlers to attach event handlers.

    +

    Delegated event handlers have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated event handlers to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.

    +

    In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated event handlers is their potential for much lower overhead when many elements must be monitored. On a data table with 1,000 rows in its tbody, this example attaches a handler to 1,000 elements:

    
     $( "#dataTable tbody tr" ).on( "click", function() {
       console.log( $( this ).text() );
    @@ -55,7 +55,7 @@ $( "#dataTable tbody" ).on( "click", "tr", function() {
       console.log( $( this ).text() );
     });
         
    -

    Note: Delegated events do not work for SVG.

    +

    Note: Delegated event handlers do not work for SVG.

    The event handler and its environment

    The handler argument is a function (or the value false, see below), and is required unless you pass an object for the events argument. You can provide an anonymous handler function at the point of the .on() call, as the examples have done above, or declare a named function and pass its name:

    
    @@ -66,7 +66,7 @@ $( "button" ).on( "click", notify );
         

    When the browser triggers an event or other JavaScript calls jQuery's .trigger() method, jQuery passes the handler an Event object it can use to analyze and change the status of the event. This object is a normalized subset of data provided by the browser; the browser's unmodified native event object is available in event.originalEvent. For example, event.type contains the event name (e.g., "resize") and event.target indicates the deepest (innermost) element where the event occurred.

    By default, most events bubble up from the original event target to the document element. At each element along the way, jQuery calls any matching event handlers that have been attached. A handler can prevent the event from bubbling further up the document tree (and thus prevent handlers on those elements from running) by calling event.stopPropagation(). Any other handlers attached on the current element will run however. To prevent that, call event.stopImmediatePropagation(). (Event handlers bound to an element are called in the same order that they were bound.)

    -

    Similarly, a handler can call event.preventDefault() to cancel any default action that the browser may have for this event; for example, the default action on a click event is to follow the link. Not all browser events have default actions, and not all default actions can be canceled. See the W3C Events Specification for details.

    +

    Similarly, a handler can call event.preventDefault() to cancel any default action that the browser may have for this event; for example, the default action on a click event is to follow the link. Not all browser events have default actions, and not all default actions can be canceled. See the W3C Events Specification for details.

    Returning false from an event handler will automatically call event.stopPropagation() and event.preventDefault(). A false value can also be passed for the handler as a shorthand for function(){ return false; }. So, $( "a.disabled" ).on( "click", false ); attaches an event handler to all links with class "disabled" that prevents them from being followed when they are clicked and also stops the event from bubbling.

    When jQuery calls a handler, the this keyword is a reference to the element where the event is being delivered; for directly bound events this is the element where the event was attached and for delegated events this is an element matching selector. (Note that this may not be equal to event.target if the event has bubbled from a descendant element.) To create a jQuery object from the element so that it can be used with jQuery methods, use $( this ).

    Passing data to the handler

    @@ -90,13 +90,13 @@ $( "button" ).on( "click", {

    Attaching many delegated event handlers near the top of the document tree can degrade performance. Each time the event occurs, jQuery must compare all selectors of all attached events of that type to every element in the path from the event target up to the top of the document. For best performance, attach delegated events at a document location as close as possible to the target elements. Avoid excessive use of document or document.body for delegated events on large documents.

    jQuery can process simple selectors of the form tag#id.class very quickly when they are used to filter delegated events. So, "#myForm", "a.external", and "button" are all fast selectors. Delegated events that use more complex selectors, particularly hierarchical ones, can be several times slower--although they are still fast enough for most applications. Hierarchical selectors can often be avoided simply by attaching the handler to a more appropriate point in the document. For example, instead of $( "body" ).on( "click", "#commentForm .addNew", addComment ) use $( "#commentForm" ).on( "click", ".addNew", addComment ).

    Additional notes

    -

    There are shorthand methods for some events such as .click() that can be used to attach or trigger event handlers. For a complete list of shorthand methods, see the events category.

    +

    Some events have dedicated pages, describing specifics of their usage. For a complete list of those events, see the events category.

    Deprecated in jQuery 1.8, removed in 1.9: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the "hover" pseudo-event-name with the .hover() method, which accepts one or two functions.

    jQuery's event system requires that a DOM element allow attaching data via a property on the element, so that events can be tracked and delivered. The object, embed, and applet elements cannot attach data, and therefore cannot have jQuery events bound to them.

    The focus and blur events are specified by the W3C to not bubble, but jQuery defines cross-browser focusin and focusout events that do bubble. When focus and blur are used to attach delegated event handlers, jQuery maps the names and delivers them as focusin and focusout respectively. For consistency and clarity, use the bubbling event type names.

    In all browsers, the load, scroll, and error events (e.g., on an <img> element) do not bubble. In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is directly attached to the element generating the event.

    The error event on the window object uses nonstandard arguments and return value conventions, so it is not supported by jQuery. Instead, assign a handler function directly to the window.onerror property.

    -

    The handler list for an element is set when the event is first delivered. Adding or removing event handlers on the current element won't take effect until the next time the event is handled. To prevent any further event handlers from executing on an element within an event handler, call event.stopImmediatePropagation(). This behavior goes against the W3C events specification. To better understand this case, consider the following code:

    +

    The handler list for an element is set when the event is first delivered. Adding or removing event handlers on the current element won't take effect until the next time the event is handled. To prevent any further event handlers from executing on an element within an event handler, call event.stopImmediatePropagation(). This behavior goes against the W3C events specification. To better understand this case, consider the following code:

    var $test = $( "#test" );
     
     function handler1() {
    @@ -161,7 +161,7 @@ $( "div" ).trigger( "click", { name: "Jim" } );
     ]]>
       
       
    -    Use the the second argument of .trigger() to pass an array of data to the event handler
    +    Use the second argument of .trigger() to pass an array of data to the event handler
         
       
       
    -    Cancel a link's default action using the .preventDefault() method.
    +    Cancel a link's default action using the .preventDefault() method:
         
    +  
    +  
    +    Attach multiple events—one on mouseenter and one on mouseleave to the same element:
    +    
       
       
    diff --git a/entries/one.xml b/entries/one.xml
    index 1327dbf0..4b98e5f9 100644
    --- a/entries/one.xml
    +++ b/entries/one.xml
    @@ -8,7 +8,7 @@
           A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
         
         
    -      An object containing data that will be passed to the event handler.
    +      Data to be passed to the handler in event.data when an event is triggered.
         
         
           A function to execute at the time the event is triggered.
    @@ -44,7 +44,7 @@
         
       
       
    -    

    The .one() method is identical to .on(), except that the handler is unbound after its first invocation. For example:

    +

    The .one() method is identical to .on(), except that the handler for a given element and event type is unbound after its first invocation. For example:

    
     $( "#foo" ).one( "click", function() {
       alert( "This will be displayed only once." );
    @@ -59,6 +59,12 @@ $( "#foo" ).on( "click", function( event ) {
         

    In other words, explicitly calling .off() from within a regularly-bound handler has exactly the same effect.

    If the first argument contains more than one space-separated event types, the event handler is called once for each event type.

    +
    
    +$( "#foo" ).one( "click mouseover", function( event ) {
    +  alert( "The " + event.type + " event happened!" );
    +});
    +    
    +

    In the example above the alert could be displayed twice due to the two event types (click and mouseover).

    Tie a one-time click to each div. diff --git a/entries/outerHeight.xml b/entries/outerHeight.xml index 38b8816d..dc53bcb3 100644 --- a/entries/outerHeight.xml +++ b/entries/outerHeight.xml @@ -1,29 +1,30 @@ - Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns a number (without "px") representation of the value or null if called on an empty set of elements. + Get the current computed outer height (including padding, border, and optionally margin) for the first element in the set of matched elements or set the outer height of every matched element. .outerHeight() 1.2.6 - + A Boolean indicating whether to include the element's margin in the calculation. - Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns a number (without "px") representation of the value or null if called on an empty set of elements. + Get the current computed outer height (including padding, border, and optionally margin) for the first element in the set of matched elements. -

    The top and bottom padding and border are always included in the .outerHeight() calculation; if the includeMargin argument is set to true, the margin (top and bottom) is also included.

    -

    This method is not applicable to window and document objects; for these, use .height() instead.

    -

    +

    Returns the height of the element, including top and bottom padding, border, and optionally margin, in pixels. If called on an empty set of elements, returns undefined (null before jQuery 3.0).

    +

    This method is not applicable to window and document objects; for these, use .height() instead. Although .outerHeight() can be used on table elements, it may give unexpected results on tables using the border-collapse: collapse CSS property.

    +
    -

    +
    Figure 1 - Illustration of the measured height
    +
    - - + + Get the outerHeight of a paragraph. @@ -46,20 +47,29 @@ $( "p:last" ).text( - 1.8.0 + 1.8 A number representing the number of pixels, or a number along with an optional unit of measure appended (as a string). + + A Boolean indicating whether to new value should account for the element's margin. + - 1.8.0 - + 1.8 + + + + + + + A function returning the outer height to set. Receives the index position of the element in the set and the old outer height as arguments. Within the function, this refers to the current element in the set. - Set the CSS outer Height of each element in the set of matched elements. + Set the CSS outer height of each element in the set of matched elements.

    When calling .outerHeight(value), the value can be either a string (number and unit) or a number. If only a number is provided for the value, jQuery assumes a pixel unit. If a string is provided, however, any valid CSS measurement may be used (such as 100px, 50%, or auto).

    diff --git a/entries/outerWidth.xml b/entries/outerWidth.xml index f5ac7b0d..2c5856be 100644 --- a/entries/outerWidth.xml +++ b/entries/outerWidth.xml @@ -1,30 +1,30 @@ - Get the current computed width for the first element in the set of matched elements, including padding and border. + Get the current computed outer width (including padding, border, and optionally margin) for the first element in the set of matched elements or set the outer width of every matched element. .outerWidth() 1.2.6 - + A Boolean indicating whether to include the element's margin in the calculation. - Get the current computed width for the first element in the set of matched elements, including padding and border. + Get the current computed outer width (including padding, border, and optionally margin) for the first element in the set of matched elements. -

    Returns the width of the element, along with left and right padding, border, and optionally margin, in pixels.

    -

    If includeMargin is omitted or false, the padding and border are included in the calculation; if true, the margin is also included.

    +

    Returns the width of the element, including left and right padding, border, and optionally margin, in pixels. If called on an empty set of elements, returns undefined (null before jQuery 3.0).

    This method is not applicable to window and document objects; for these, use .width() instead. Although .outerWidth() can be used on table elements, it may give unexpected results on tables using the border-collapse: collapse CSS property.

    -

    +

    -

    +
    Figure 1 - Illustration of the measured width
    +
    - - + + Get the outerWidth of a paragraph. @@ -44,18 +44,28 @@ $( "p:last" ).text(
    + - 1.8.0 + 1.8 A number representing the number of pixels, or a number along with an optional unit of measure appended (as a string). + + A Boolean indicating whether to new value should account for the element's margin. + - 1.8.0 - + 1.8 + + + + + + + A function returning the outer width to set. Receives the index position of the element in the set and the old outer width as arguments. Within the function, this refers to the current element in the set. @@ -63,7 +73,7 @@ $( "p:last" ).text(

    When calling .outerWidth(value), the value can be either a string (number and unit) or a number. If only a number is provided for the value, jQuery assumes a pixel unit. If a string is provided, however, any valid CSS measurement may be used (such as 100px, 50%, or auto).

    - + Change the outer width of each div the first time it is clicked (and change its color). d
    ]]>
    - + diff --git a/entries/parent-selector.xml b/entries/parent-selector.xml index 424cd36e..bd3fd743 100644 --- a/entries/parent-selector.xml +++ b/entries/parent-selector.xml @@ -9,7 +9,7 @@

    This is the inverse of :empty.

    One important thing to note regarding the use of :parent (and :empty) is that child nodes include text nodes.

    -

    The W3C recommends that the <p> element have at least one child node, even if that child is merely text (see http://www.w3.org/TR/html401/struct/text.html#edef-P). Some other elements, on the other hand, are empty (i.e. have no children) by definition: <input>, <img>, <br>, and <hr>, for example.

    +

    The W3C recommends that the <p> element have at least one child node, even if that child is merely text (see https://www.w3.org/TR/html401/struct/text.html#edef-P). Some other elements, on the other hand, are empty (i.e. have no children) by definition: <input>, <img>, <br>, and <hr>, for example.

    To obtain the parents or ancestors of an existing jQuery set, see the .parent() and .parents() methods.

    diff --git a/entries/parents.xml b/entries/parents.xml index 403b2393..ab51cde9 100644 --- a/entries/parents.xml +++ b/entries/parents.xml @@ -82,7 +82,7 @@ function showParents() { .length; $( "b" ).text( "Unique div parents: " + len ); } -$( "span" ).click(function() { +$( "span" ).on( "click", function() { $( this ).toggleClass( "selected" ); showParents(); }); diff --git a/entries/password-selector.xml b/entries/password-selector.xml index 8d632b8f..053e0dc2 100644 --- a/entries/password-selector.xml +++ b/entries/password-selector.xml @@ -13,18 +13,18 @@ Finds all password inputs. Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. -

    The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

    +

    The .position() method allows us to retrieve the current position of an element (specifically its margin box) relative to the offset parent (specifically its padding box, which excludes margins and borders). Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

    Returns an object containing the properties top and left.

    -

    Note: jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.

    +

    Note: jQuery does not support getting the position coordinates of hidden elements or accounting for margins set on the <html> document element.

    - + Access the position of the second paragraph: 1.0 - DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + DOM element, text node, array of elements and text nodes, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + + - One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + One or more additional DOM elements, text nodes, arrays of elements and text nodes, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. @@ -26,9 +28,10 @@ + - A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + A function that returns an HTML string, DOM element(s), text node(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. @@ -78,7 +81,7 @@ $( ".container" ).prepend( $( "h2" ) );

    Similar to other content-adding methods such as .append() and .before(), .prepend() also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.

    For example, the following will insert two new <div>s and an existing <div> as the first three child nodes of the body:

    
    -var $newdiv1 = $( "<div id='object1'/>"),
    +var $newdiv1 = $( "<div id='object1'></div>"),
       newdiv2 = document.createElement( "div" ),
       existingdiv1 = document.getElementById( "foo" );
     
    @@ -87,6 +90,7 @@ $( "body" ).prepend( $newdiv1, [ newdiv2, existingdiv1 ] );
         

    Since .prepend() can accept any number of additional arguments, the same result can be achieved by passing in the three <div>s as three separate arguments, like so: $( "body" ).prepend( $newdiv1, newdiv2, existingdiv1 ). The type and number of arguments will largely depend on how you collect the elements in your code.

    + Prepends some HTML to all paragraphs. If there is more than one target element, however, cloned copies of the inserted element will be created for each target except the last.

    + Prepend all spans to the element with the ID "foo" (Check .prepend() documentation for more examples) A string containing a selector expression to match elements against. - Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. + Get the immediately preceding sibling of each element in the set of matched elements. If a selector is provided, it retrieves the previous sibling only if it matches that selector.

    Given a jQuery object that represents a set of DOM elements, the .prev() method searches for the predecessor of each of these elements in the DOM tree and constructs a new jQuery object from the matching elements.

    The method optionally accepts a selector expression of the same type that can be passed to the $() function. If the selector is supplied, the preceding element will be filtered by testing whether it match the selector.

    @@ -34,7 +34,7 @@ $( "li.third-item" ).prev().css( "background-color", "red" ); A string containing a selector expression to match elements against. - Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. + Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector, in the reverse document order.

    Given a jQuery object that represents a set of DOM elements, the .prevAll() method searches through the predecessors of these elements in the DOM tree and construct a new jQuery object from the matching elements; the elements are returned in order beginning with the closest sibling.

    The method optionally accepts a selector expression of the same type that we can pass to the $() function. If the selector is supplied, the elements will be filtered by testing whether they match it.

    @@ -26,11 +26,48 @@ $( "li.third-item" ).prevAll().css( "background-color", "red" );

    The result of this call is a red background behind items 1 and 2. Since we do not supply a selector expression, these preceding elements are unequivocally included as part of the object. If we had supplied one, the elements would be tested for a match before they were included.

    +

    Note: Many APIs, like append or wrapAll process node in the order in which they appear in the jQuery object. This can pose issues with APIs like .prevAll() in which the reverse document order is used. Consider the following example:

    +
    
    +<div>
    +  <div>First</div>
    +  <div>Second</div>
    +  <div class="last-item">Last</div>
    +</div>
    +    
    +

    The following call:

    +
    
    +$( ".last-item" )
    +  .prevAll()
    +  .wrapAll( "<div class='wrapper'></div>" );
    +    
    +

    would result in the following HTML:

    +
    
    +<div>
    +  <div class="wrapper">
    +    <div>Second</div>
    +    <div>First</div>
    +  </div>
    +  <div class="last-item">Last</div>
    +</div>
    +    
    +

    because "Item 2" gets appended to the wrapper div first. To work around the issue, you may use .uniqueSort() on the .prevAll() output first:

    +
    
    +$( ".last-item" )
    +  .prevAll()
    +  .uniqueSort()
    +  .wrapAll( "<div class='wrapper'></div>" );
    +    
    +

    Note that the .uniqueSort() method is only available in jQuery 3.7.0 or newer. In older versions, you will need to use $.uniqueSort() to achieve a similar effect:

    +
    
    +var prevSiblings = $( ".last-item" ).prevAll();
    +$.uniqueSort( prevSiblings );
    +prevSiblings.wrapAll( "<div class='wrapper'></div>" );
    +    
    Locate all the divs preceding the last div and give them a class.
    +]]> +
    + + Locate all the divs preceding the last item and wrap them with a div with class wrapper - with or without .uniqueSort(). + " ); + +$( "#container-2" ) + .find( ".item" ) + .last() + .prevAll() + .uniqueSort() + .wrapAll( "
    " ); +]]>
    + + +
    1
    +
    2
    +
    3
    + + +
    +
    1
    +
    2
    +
    3
    +
    ]]>
    diff --git a/entries/prop.xml b/entries/prop.xml index adccbc85..5506d40b 100644 --- a/entries/prop.xml +++ b/entries/prop.xml @@ -42,17 +42,10 @@ $( elem ).attr( "checked" ) - (1.6) + (1.6+) "checked" (String) Initial state of the checkbox; does not change - - - $( elem ).attr( "checked" ) - (1.6.1+) - - "checked" (String) Will change with checkbox state - $( elem ).attr( "checked" ) @@ -62,7 +55,7 @@
    -

    According to the W3C forms specification, the checked attribute is a boolean attribute, which means the corresponding property is true if the attribute is present at all—even if, for example, the attribute has no value or is set to empty string value or even "false". This is true of all boolean attributes.

    +

    According to the W3C forms specification, the checked attribute is a boolean attribute, which means the corresponding property is true if the attribute is present at all—even if, for example, the attribute has no value or is set to empty string value or even "false". This is true of all boolean attributes.

    Nevertheless, the most important concept to remember about the checked attribute is that it does not correspond to the checked property. The attribute actually corresponds to the defaultChecked property and should be used only to set the initial value of the checkbox. The checked attribute value does not change with the state of the checkbox, while the checked property does. Therefore, the cross-browser-compatible way to determine if a checkbox is checked is to use the property:

    • @@ -81,13 +74,13 @@ Display the checked property and attribute of a checkbox as it changes. " + $input.attr( "checked" ) + "
      " + ".prop( \"checked\" ): " + $input.prop( "checked" ) + "
      " + - ".is( \":checked\" ): " + $input.is( ":checked" ) ) + ""; -}).change(); + ".is( \":checked\" ): " + $input.is( ":checked" ) + "" ); +} ).trigger( "change" ); ]]>
    -

    Important: the .removeProp() method should not be used to set these properties to false. Once a native property is removed, it cannot be added again. See .removeProp() for more information.

    +

    Important: the .removeProp() method should not be used to remove native properties. This will lead to unexpected behavior. See .removeProp() for more information.

    Computed property values

    By using a function to set properties, you can compute the value based on other properties of the element. For example, to toggle all checkboxes based off their individual values:

    
    diff --git a/entries/queue.xml b/entries/queue.xml
    index 08c5f09a..ec66c39f 100644
    --- a/entries/queue.xml
    +++ b/entries/queue.xml
    @@ -119,19 +119,19 @@ $( "#test" ).queue(function( next ) {
         
           Queue a custom function.
           
           
           Set a queue array to delete the queue.
           " )
       .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();
    -});
    +} );
     ]]>
         
       
       
    -    

    While JavaScript provides the load event for executing code when a page is rendered, this event does not get triggered until all assets such as images have been completely received. In most cases, the script can be run as soon as the DOM hierarchy has been fully constructed. The handler passed to .ready() is guaranteed to be executed after the DOM is ready, so this is usually the best place to attach all other event handlers and run other jQuery code. When using scripts that rely on the value of CSS style properties, it's important to reference external stylesheets or embed style elements before referencing the scripts.

    -

    In cases where code relies on loaded assets (for example, if the dimensions of an image are required), the code should be placed in a handler for the load event instead.

    -
    -

    The .ready() method is generally incompatible with the <body onload=""> attribute. If load must be used, either do not use .ready() or use jQuery's .load() method to attach load event handlers to the window or to more specific items, like images. -

    -
    -

    All three of the following syntaxes are equivalent:

    +

    The .ready() method offers a way to run JavaScript code as soon as the page's Document Object Model (DOM) becomes safe to manipulate. This will often be a good time to perform tasks that are needed before the user views or interacts with the page, for example to add event handlers and initialize plugins. When multiple functions are added via successive calls to this method, they run when the DOM is ready in the order in which they are added. As of jQuery 3.0, jQuery ensures that an exception occuring in one handler does not prevent subsequently added handlers from executing.

    + +

    Most browsers provide similar functionality in the form of a DOMContentLoaded event. However, jQuery's .ready() method differs in an important and useful way: If the DOM becomes ready and the browser fires DOMContentLoaded before the code calls .ready( handler ), the function handler will still be executed. In contrast, a DOMContentLoaded event listener added after the event fires is never executed.

    + +

    Browsers also provide the load event on the window object. When this event fires it indicates that all assets on the page have loaded, including images. This event can be watched in jQuery using $( window ).on( "load", handler ). In cases where code relies on loaded assets (for example, if the dimensions of an image are required), the code should be placed in a handler for the load event instead.

    + +

    Note that although the DOM always becomes ready before the page is fully loaded, it is usually not safe to attach a load event listener in code executed during a .ready() handler. For example, scripts can be loaded dynamically long after the page has loaded using methods such as $.getScript(). Although handlers added by .ready() will always be executed in a dynamically loaded script, the window's load event has already occurred and those listeners will never run.

    + +

    jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

    +
      -
    • - $( document ).ready( handler ) -
    • -
    • $().ready( handler ) (this is not recommended)
    • -
    • - $( handler ) -
    • +
    • $( handler )
    • +
    • $( document ).ready( handler )
    • +
    • $( "document" ).ready( handler )
    • +
    • $( "img" ).ready( handler )
    • +
    • $().ready( handler )
    -

    There is also $(document).on( "ready", handler ), deprecated as of jQuery 1.8. This behaves similarly to the ready method but if the ready event has already fired and you try to .on( "ready" ) the bound handler will not be executed. Ready handlers bound this way are executed after any bound by the other three methods above.

    -

    The .ready() method can only be called on a jQuery object matching the current document, so the selector can be omitted.

    + +

    As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated. This is because the selection has no bearing on the behavior of the .ready() method, which is inefficient and can lead to incorrect assumptions about the method's behavior. For example, the third syntax works with "document" which selects nothing. The fourth syntax waits for the document to be ready but implies (incorrectly) that it waits for images to become ready.

    + +

    There is also $(document).on( "ready", handler ), deprecated as of jQuery 1.8 and removed in jQuery 3.0. Note that if the DOM becomes ready before this event is attached, the handler will not be executed.

    +

    The .ready() method is typically used with an anonymous function:

    
     $( document ).ready(function() {
       // Handler for .ready() called.
     });
         
    -

    Which is equivalent to calling:

    +

    Which is equivalent to the recommended way of calling:

    
     $(function() {
       // Handler for .ready() called.
     });
         
    -

    If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.

    -

    Aliasing the jQuery Namespace

    -

    When using another JavaScript library, we may wish to call $.noConflict() to avoid namespace difficulties. When this function is called, the $ shortcut is no longer available, forcing us to write jQuery each time we would normally write $. However, the handler passed to the .ready() method can take an argument, which is passed the global jQuery object. This means we can rename the object within the context of our .ready() handler without affecting other code:

    +

    Aliasing the jQuery Object

    +

    When $.noConflict() is used to avoid namespace conflicts, the $ shortcut is no longer available. However, the .ready() handler is passed a reference to the jQuery object that called the method. This allows the handler to use a jQuery object, for example as $, without knowing its aliased name:

    
    -jQuery( document ).ready(function( $ ) {
    -  // Code using $ as usual goes here.
    +jq2 = jQuery.noConflict();
    +jq2(function( $ ) {
    +  // Code using $ as usual goes here; the actual jQuery object is jq2
     });
         
    Display a message when the DOM is loaded. diff --git a/entries/remove.xml b/entries/remove.xml index 6c85e9b4..4a7ab41c 100644 --- a/entries/remove.xml +++ b/entries/remove.xml @@ -42,9 +42,9 @@ $( "div" ).remove( ".hello" ); Removes all paragraphs from the DOM Removes all paragraphs that contain "Hello" from the DOM. Analogous to doing $("p").filter(":contains('Hello')").remove(). diff --git a/entries/removeAttr.xml b/entries/removeAttr.xml index 0dd1abea..6df34820 100644 --- a/entries/removeAttr.xml +++ b/entries/removeAttr.xml @@ -10,18 +10,19 @@ Remove an attribute from each element in the set of matched elements.

    The .removeAttr() method uses the JavaScript removeAttribute() function, but it has the advantage of being able to be called directly on a jQuery object and it accounts for different attribute naming across browsers.

    -

    Note: Removing an inline onclick event handler using .removeAttr() doesn't achieve the desired effect in Internet Explorer 6, 7, or 8. To avoid potential problems, use .prop() instead:

    +

    Note: Removing an inline onclick event handler using .removeAttr() doesn't achieve the desired effect in Internet Explorer 8, 9 and 11. To avoid potential problems, use .prop() instead:

    
     $element.prop( "onclick", null );
     console.log( "onclick property: ", $element[ 0 ].onclick );
         
    +
    Clicking the button changes the title of the input next to it. Move the mouse pointer over the text input to see the effect of adding and removing the title attribute. - - .removeClass() - - 1.0 - - One or more space-separated classes to be removed from the class attribute of each matched element. - - - - 1.4 - - - - - A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. - - + Remove a single class, multiple classes, or all classes from each element in the set of matched elements. - -

    If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no class names are specified in the parameter, all classes will be removed.

    -

    More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:

    -
    
    -$( "p" ).removeClass( "myClass yourClass" )
    -    
    -

    This method is often used with .addClass() to switch elements' classes from one to another, like so:

    -
    
    -$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
    -    
    -

    Here, the myClass and noClass classes are removed from all paragraphs, while yourClass is added.

    -

    To replace all existing classes with another class, we can use .attr( "class", "newClass" ) instead.

    -

    As of jQuery 1.4, the .removeClass() method allows us to indicate the class to be removed by passing in a function.

    -
    
    -$( "li:last" ).removeClass(function() {
    -  return $( this ).prev().attr( "class" );
    -});
    -    
    -

    This example removes the class name of the penultimate <li> from the last <li>.

    -
    - - Remove the class 'blue' from the matched elements. - - - Hello

    -

    and

    -

    then

    -

    Goodbye

    -]]> -
    - - Remove the class 'blue' and 'under' from the matched elements. - - - Hello

    -

    and

    -

    then

    -

    Goodbye

    -]]> -
    - - Remove all the classes from the matched elements. - - - Hello

    -

    and

    -

    then

    -

    Goodbye

    -]]> -
    - - - - - -
    + + .removeClass() + + 1.0 + + One or more space-separated classes to be removed from the class attribute of each matched element. + + + + 3.3 + + An array of classes to be removed from the class attribute of each matched element. + + + + 1.4 + + + + + A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + + + + 3.3 + + + + + + A function returning one or more space-separated class names or an array of class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + + + Remove a single class or multiple classes from each element in the set of matched elements. + +

    Before jQuery version 1.12/2.2, the .removeClass() method manipulated the className property of the selected elements, not the class attribute. Once the property was changed, it was the browser that updated the attribute accordingly. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).

    +

    As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the class attribute is used instead. So, .removeClass() can be used on XML or SVG documents.

    +

    More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:

    +
    
    +  $( "p" ).removeClass( "myClass yourClass" )
    +      
    +

    This method is often used with .addClass() to switch elements' classes from one to another, like so:

    +
    
    +  $( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
    +      
    +

    Here, the myClass and noClass classes are removed from all paragraphs, while yourClass is added.

    +

    To replace all existing classes with another class, we can use .attr( "class", "newClass" ) instead.

    +

    As of jQuery 1.4, the .removeClass() method allows us to indicate the class to be removed by passing in a function.

    +
    
    +  $( "li" ).last().removeClass(function() {
    +    return $( this ).prev().attr( "class" );
    +  });
    +      
    +

    This example removes the class name of the penultimate <li> from the last <li>.

    +
    + + Remove the class 'blue' from the matched elements. + + + Hello

    +

    and

    +

    then

    +

    Goodbye

    + ]]> +
    + + Remove the class 'blue' and 'under' from the matched elements. + + + Hello

    +

    and

    +

    then

    +

    Goodbye

    + ]]> +
    + + Remove the class 'blue' and 'under' from the matched elements (3.3+ syntax). + + + Hello

    +

    and

    +

    then

    +

    Goodbye

    + ]]> +
    + + + + + + + +
    + + + + 1.0 + + Remove all classes from each matched element. + +

    Before jQuery version 1.12/2.2, the .removeClass() method manipulated the className property of the selected elements, not the class attribute. Once the property was changed, it was the browser that updated the attribute accordingly. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).

    +

    As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the class attribute is used instead. So, .removeClass() can be used on XML or SVG documents.

    +
    + + Remove all the classes from the matched elements. + + + Hello

    +

    and

    +

    then

    +

    Goodbye

    + ]]> +
    + + + + + +
    + diff --git a/entries/removeData.xml b/entries/removeData.xml index 3c2cf8ff..e4dd08b1 100644 --- a/entries/removeData.xml +++ b/entries/removeData.xml @@ -28,13 +28,13 @@ Set a data store for 2 names then remove one of them. Remove a property for the set of matched elements.

    The .removeProp() method removes properties set by the .prop() method.

    -

    With some built-in properties of a DOM element or window object, browsers may generate an error if an attempt is made to remove the property. jQuery first assigns the value undefined to the property and ignores any error the browser generates. In general, it is only necessary to remove custom properties that have been set on an object, and not built-in (native) properties.

    -

    Note: Do not use this method to remove native properties such as checked, disabled, or selected. This will remove the property completely and, once removed, cannot be added again to element. Use .prop() to set these properties to false instead.

    +

    Note:This method should not be used to remove built-in (native) properties such as "checked", "disabled", "selected", or others. This can lead to unexpected behavior.

    +

    It's almost always better to use .prop() to set native properties to false instead of removing them.

    diff --git a/entries/replaceWith.xml b/entries/replaceWith.xml index dfdd39a7..219e3e64 100644 --- a/entries/replaceWith.xml +++ b/entries/replaceWith.xml @@ -69,7 +69,7 @@ $( "div.third" ).replaceWith( $( ".first" ) ); On click, replace the button with a div containing the same word. " + $( this ).text() + "" ); }); ]]> @@ -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() + Bind an event handler to the "resize" 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 .resize( handler ) or .resize( eventData, handler ), use .on( "resize", handler ) or .on( "resize", eventData, handler ), respectively.

    +

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

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

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

    +
    +

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

    +

    The resize event is sent to the window element when the size of the browser window changes:

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

    Now whenever the browser window's size is changed, the message is appended to <div id="log"> one or more times, depending on the browser.

    Code in a resize handler should never rely on the number of times the handler is called. Depending on implementation, resize events can be sent continuously as the resizing is in progress (the typical behavior in Internet Explorer and WebKit-based browsers such as Safari and Chrome), or only once at the end of the resize operation (the typical behavior in some other browsers such as Opera).

    @@ -36,12 +34,30 @@ $( window ).resize(function() { To see the window width while (or after) it is resized, try: " + $( window ).width() + "" ); -}); +} ); ]]> - + +
    + + + 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 372d6c64..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,26 +39,27 @@
       Trigger the handler
     </div>
     <div id="log"></div>
    -
    +

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

    -

    +

    -

    +
    Figure 1 - Illustration of the rendered HTML
    +

    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.

    @@ -71,9 +70,9 @@ $( "#other" ).click(function() { $( "p" ).clone().appendTo( document.body ); $( "p" ).clone().appendTo( document.body ); $( "p" ).clone().appendTo( document.body ); -$( window ).scroll(function() { +$( window ).on( "scroll", function() { $( "span" ).css( "display", "inline" ).fadeOut( "slow" ); -}); +} ); ]]>
    - + + + + + scroll event + Trigger the "scroll" event on an element. + + 1.0 + + The string "scroll". + + + +

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

    +
    + +
    + + diff --git a/entries/scrollLeft.xml b/entries/scrollLeft.xml index 2b53896b..7fe21491 100644 --- a/entries/scrollLeft.xml +++ b/entries/scrollLeft.xml @@ -16,8 +16,8 @@ Get the scrollLeft of a paragraph. - + .scrollTop() 1.2.6 @@ -12,8 +12,8 @@ Get the scrollTop of a paragraph. 1.2.6 - An integer indicating the new position to set the scroll bar to. + A number indicating the new position to set the scroll bar to. Set the current vertical position of the scroll bar for each of the set of matched elements. diff --git a/entries/select-shorthand.xml b/entries/select-shorthand.xml new file mode 100644 index 00000000..e3fb0227 --- /dev/null +++ b/entries/select-shorthand.xml @@ -0,0 +1,36 @@ + + + .select() + Bind an event handler to the "select" 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 .select( handler ) or .select( eventData, handler ), use .on( "select", handler ) or .on( "select", eventData, handler ), respectively.

    +

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

    +
    +
    + + + + +
    diff --git a/entries/select.xml b/entries/select.xml index 597c0f1d..60573881 100644 --- a/entries/select.xml +++ b/entries/select.xml @@ -1,16 +1,15 @@ - - .select() - Bind an event handler to the "select" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "select" event, or trigger that event on an element. + + + select event + Bind an event handler to the "select" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "select". - - - 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( "select", handler ) in the first two variations, and .trigger( "select" ) in the third.

    +
    +

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

    +

    The select event is sent to an element when the user makes a text selection inside it. This event is limited to <input type="text"> fields and <textarea> boxes.

    For example, consider the HTML:

    
    @@ -35,19 +33,19 @@
     </div>

    The event handler can be bound to the text input:

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

    Now when any portion of the text is selected, the alert is displayed. Merely setting the location of the insertion point will not trigger the event. To trigger the event manually, apply .select() without an argument:

    +

    Now when any portion of the text is selected, the alert is displayed. Merely setting the location of the insertion point will not trigger the event. To trigger the event manually, use .trigger( "select" ):

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

    After this code executes, clicks on the Trigger button will also alert the message:

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

    In addition, the default select action on the field will be fired, so the entire text field will be selected.

    @@ -57,9 +55,9 @@ $( "#other").click(function() { To do something when text in input boxes is selected: To trigger the select event on all input elements, try: - + + + + + 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. - + .selector 1.3 A selector representing selector passed to jQuery(), if any, when creating the original set. -

    The .selector property was deprecated in jQuery 1.7 and is only maintained to the extent needed for supporting .live() in the jQuery Migrate plugin. It may be removed without notice in a future version. The property was never a reliable indicator of the selector that could be used to obtain the set of elements currently contained in the jQuery set where it was a property, since subsequent traversal methods may have changed the set. Plugins that need to use a selector string within their plugin can require it as a parameter of the method. For example, a "foo" plugin could be written as $.fn.foo = function( selector, options ) { /* plugin code goes here */ };, and the person using the plugin would write $( "div.bar" ).foo( "div.bar", {dog: "bark"} ); with the "div.bar" selector repeated as the first argument of .foo().

    +
    +

    Note: This API has been removed in jQuery 3.0. The property was never a reliable indicator of the selector that could be used to obtain the set of elements currently contained in the jQuery set where it was a property, since subsequent traversal methods may have changed the set. Plugins that need to use a selector string within their plugin can require it as a parameter of the method. For example, a "foo" plugin could be written as $.fn.foo = function( selector, options ) { /* plugin code goes here */ };, and the person using the plugin would write $( "div.bar" ).foo( "div.bar", {dog: "bark"} ); with the "div.bar" selector repeated as the first argument of .foo().

    +
    - + diff --git a/entries/serialize.xml b/entries/serialize.xml index c5c99ccb..55dd099f 100644 --- a/entries/serialize.xml +++ b/entries/serialize.xml @@ -15,7 +15,7 @@ $( "form" ).on( "submit", function( event ) { });

    In this case, jQuery serializes the successful controls within the form. Only form elements are examined for inputs they contain, in all other cases the input elements to be serialized should be part of the set passed to the .serialize() method. Selecting both the form and its children in a set will cause duplicates in the serialized string.

    -

    Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

    +

    Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

    Serialize a form to a query string that could be sent to a server in an Ajax request. diff --git a/entries/serializeArray.xml b/entries/serializeArray.xml index bc46e920..09125d06 100644 --- a/entries/serializeArray.xml +++ b/entries/serializeArray.xml @@ -28,13 +28,13 @@ </div> </form>
    -

    The .serializeArray() method uses the standard W3C rules for successful controls to determine which elements it should include; in particular the element cannot be disabled and must contain a name attribute. No submit button value is serialized since the form was not submitted using a button. Data from file select elements is not serialized.

    +

    The .serializeArray() method uses the standard W3C rules for successful controls to determine which elements it should include; in particular the element cannot be disabled and must contain a name attribute. No submit button value is serialized since the form was not submitted using a button. Data from file select elements is not serialized. Elements that do not contain a value attribute are represented with the empty string value.

    This method can act on a jQuery object that has selected individual form controls, such as <input>, <textarea>, and <select>. However, it is typically easier to select the <form> element itself for serialization:

    
    -$( "form" ).submit(function( event ) {
    +$( "form" ).on( "submit", function( event ) {
       console.log( $( this ).serializeArray() );
       event.preventDefault();
    -});
    +} );
         

    This produces the following data structure (provided that the browser supports console.log):

    
    @@ -70,11 +70,11 @@ $( "form" ).submit(function( event ) {
         $( "#results" ).empty();
         jQuery.each( fields, function( i, field ) {
           $( "#results" ).append( field.value + " " );
    -    });
    +    } );
       }
     
    -  $( ":checkbox, :radio" ).click( showValues );
    -  $( "select" ).change( showValues );
    +  $( ":checkbox, :radio" ).on( "click", showValues );
    +  $( "select" ).on( "change", showValues );
       showValues();
     ]]>
         
     $( ".target" ).show();
         
    -

    The matched elements will be revealed immediately, with no animation. This is roughly equivalent to calling .css( "display", "block"), except that the display property is restored to whatever it was initially. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.

    -

    Note: If using !important in your styles, such as - display: none !important, - it is necessary to override the style using .css( "display", "block !important") should you wish for .show() to function correctly.

    +

    The matched elements will be revealed immediately, with no animation. This is roughly equivalent to calling .css( "display", "block" ), except that the display property is restored to whatever it was initially. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.

    +

    Note: If using !important in your styles, such as display: none !important, .show() will not override !important. + It is recommended to use different classes with .addClass(), .removeClass() or .toggleClass(). Another approach is using .attr( "style", "display: block !important;" ); be careful, though, as it overwrites the style attribute of the element.

    When a duration, a plain object, or a "complete" function is provided, .show() becomes an animation method. The .show() method animates the width, height, and opacity of the matched elements simultaneously.

    Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    +
    +

    Note: This method may cause performance issues, especially when used on many elements. If you're encountering such issues, use performance testing tools to determine whether this method is causing them. Moreover, this method can cause problems with responsive layouts if the display value differs at different viewport sizes.

    +

    We can animate any element, such as a simple image:

    
     <div id="clickme">
    @@ -47,24 +49,25 @@ $( ".target" ).show();
     </div>
     <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" ).show( "slow", function() {
         // Animation complete.
       });
     });
         
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the show() effect
    +
    Animates all hidden paragraphs to show slowly, completing the animation within 600 milliseconds. @@ -81,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. @@ -117,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(); -}); +} ); ]]> - + .size() 1.0 Return the number of elements in the jQuery object. -

    The .size() method is deprecated as of jQuery 1.8. Use the .length property instead.

    +
    +

    Note: This method has been removed in jQuery 3.0. Use the .length property instead.

    +

    The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.

    Given a simple unordered list on the page:

    @@ -30,40 +32,21 @@ alert( "Size: " + $( "li" ).length );

    - Count the divs. Click to add more. + Count the divs. " ) ); var n = $( "div" ).size(); $( "span" ).text( "There are " + n + " divs. Click to add more." ); - }) + } ) // Trigger the click to start - .click(); + .trigger( "click" ); ]]> - - -
    -]]>
    +
    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 ); ]]>

    With the element initially hidden, we can show it slowly:

    
    -$( "#clickme" ).click(function() {
    +$( "#clickme" ).on( "click", function() {
       $( "#book" ).slideDown( "slow", function() {
         // Animation complete.
       });
     });
         
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the slideDown() effect
    +

    Easing

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -53,13 +54,13 @@ $( "#clickme" ).click(function() { Animates all divs to slide down and show themselves over 600 milliseconds. Animates all inputs to slide down, completing the animation within 1000 milliseconds. Once the animation is done, the input look is changed especially if it is the middle input which gets the focus.

    We will cause .slideToggle() to be called when another element is clicked:

    
    -$( "#clickme" ).click(function() {
    +$( "#clickme" ).on( "click", function() {
       $( "#book" ).slideToggle( "slow", function() {
         // Animation complete.
       });
     });
         

    With the element initially shown, we can hide it slowly with the first click:

    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the slideToggle() effect when hiding the image
    +

    A second click will show the element once again:

    -

    - - - - -

    +
    + + + + +
    Figure 2 - Illustration of the slideToggle() effect when showing the image
    +

    Easing

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -61,7 +63,7 @@ $( "#clickme" ).click(function() { Animates all paragraphs to slide up or down, completing the animation within 600 milliseconds. @@ -82,7 +84,7 @@ $( "button" ).click(function() { Animates divs between dividers with a toggle that makes some appear and some disappear.

    With the element initially shown, we can hide it slowly:

    
    -$( "#clickme" ).click(function() {
    +$( "#clickme" ).on( "click", function() {
       $( "#book" ).slideUp( "slow", function() {
         // Animation complete.
       });
     });
         
    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the slideUp() effect
    +

    Easing

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    Callback Function

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

    @@ -53,13 +54,13 @@ $( "#clickme" ).click(function() { Animates all divs to slide up, completing the animation within 400 milliseconds. Animates the parent paragraph to slide up, completing the animation within 200 milliseconds. Once the animation is done, it displays an alert. Stop the currently-running animation on the matched elements. 1.2 - + A Boolean indicating whether to remove queued animation as well. Defaults to false. - + A Boolean indicating whether to complete the current animation immediately. Defaults to false. @@ -16,10 +16,10 @@ The name of the queue in which to stop animations. - + A Boolean indicating whether to remove queued animation as well. Defaults to false. - + A Boolean indicating whether to complete the current animation immediately. Defaults to false. @@ -53,17 +53,17 @@ $( "#hoverme-stop-2" ).hover(function() { Click the Go button once to start the animation, then click the STOP button to stop it where it's currently positioned. Another option is to click several buttons to queue them up and see that stop just kills the currently playing one. 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 @@ " + inputEl[ 0 ].nodeName + inputType + "" ); -}) +} ); ]]> + + .submit() + Bind an event handler to the "submit" 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 .submit( handler ) or .submit( eventData, handler ), use .on( "submit", handler ) or .on( "submit", eventData, handler ), respectively.

    +

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

    +
    +
    + + + + +
    diff --git a/entries/submit.xml b/entries/submit.xml index 28666420..42a32ea1 100644 --- a/entries/submit.xml +++ b/entries/submit.xml @@ -1,16 +1,15 @@ - - .submit() - Bind an event handler to the "submit" JavaScript event, or trigger that event on an element. + +Bind an event handler to the "submit" event, or trigger that event on an element. + + + submit event + Bind an event handler to the "submit" event. - 1.0 - - A function to execute each time the event is triggered. - + 1.7 + + The string "submit". - - - 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( "submit", handler ) in the first variation, and .trigger( "submit" ) in the third.

    +
    +

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

    +

    The submit event is sent to an element when the user is attempting to submit a form. It can only be attached to <form> elements. Forms can be submitted either by clicking an explicit <input type="submit">, <input type="image">, or <button type="submit">, or by pressing Enter when certain form elements have focus.

    Depending on the browser, the Enter key may only cause a form submission if the form has exactly one text field, or only when there is a submit button present. The interface should not rely on a particular behavior for this key unless the issue is forced by observing the keypress event for presses of the Enter key.

    @@ -39,16 +37,16 @@ </div>

    The event handler can be bound to the form:

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

    Now when the form is submitted, the message is alerted. This happens prior to the actual submission, so we can cancel the submit action by calling .preventDefault() on the event object or by returning false from our handler. We can trigger the event manually when another element is clicked:

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

    After this code executes, clicks on Trigger the handler will also display the message. In addition, the default submit action on the form will be fired, so the form will be submitted.

    The JavaScript submit event does not bubble in Internet Explorer. However, scripts that rely on event delegation with the submit event will work consistently across browsers as of jQuery 1.4, which has normalized the event's behavior.

    @@ -57,15 +55,15 @@ $( "#other" ).click(function() { If you'd like to prevent forms from being submitted unless a flag variable is set, try: If you'd like to prevent forms from being submitted unless a flag variable is set, try: 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/target-selector.xml b/entries/target-selector.xml index 5d60f3da..b010a5ce 100644 --- a/entries/target-selector.xml +++ b/entries/target-selector.xml @@ -7,8 +7,8 @@ Selects the target element indicated by the fragment identifier of the document's URI. -

    If the document's URI contains a fragment identifier, or hash, then the :target selector will match the element with an ID that matches the identifier. For example, given a document with a URI of http://example.com/#foo, $( "p:target" ) will select the <p id="foo"> element.

    -

    Further discussion of this usage can be found in the W3C CSS specification.

    +

    If the document's URI contains a fragment identifier, or hash, then the :target selector will match the element with an ID that matches the identifier. For example, given a document with a URI of https://example.com/#foo, $( "p:target" ) will select the <p id="foo"> element.

    +

    Further discussion of this usage can be found in the W3C CSS specification.

    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. Demonstration Box list item 1 list item 2

    -

    The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.

    +

    The .text() method should not be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.

    As of jQuery 1.4, the .text() method returns the value of text and CDATA nodes as well as element nodes.

    Find the text in the first paragraph (stripping out the html), then set the html of the last paragraph to show it is just text (the red bold is gone). <p>This is a test</p>
    -

    The .text() method cannot be used on input elements. For input field text, use the .val() method.

    +

    The .text() method should not be used on input elements. For input field text, use the .val() method.

    As of jQuery 1.4, the .text() method allows us to set the text content by passing in a function.

    
     $( "ul li" ).text(function( index ) {
    diff --git a/entries/toggle.xml b/entries/toggle.xml
    index 87cc15ce..7d74577f 100644
    --- a/entries/toggle.xml
    +++ b/entries/toggle.xml
    @@ -40,7 +40,7 @@ $( ".target" ).toggle();
         

    The matched elements will be revealed or hidden immediately, with no animation, by changing the CSS display property. If the element is initially displayed, it will be hidden; if hidden, it will be shown. The display property is saved and restored as needed. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.

    When a duration, a plain object, or a single "complete" function is provided, .toggle() becomes an animation method. The .toggle() method animates the width, height, and opacity of the matched elements simultaneously. When these properties reach 0 after a hiding animation, the display style property is set to none to ensure that the element no longer affects the layout of the page.

    Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    -

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    +

    As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

    If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but this is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.

    We can animate any element, such as a simple image:

    
    @@ -51,7 +51,7 @@ $( ".target" ).toggle();
         

    We will cause .toggle() to be called when another element is clicked:

    
    -$( "#clickme" ).click(function() {
    +$( "#clickme" ).on( "click", function() {
       $( "#book" ).toggle( "slow", function() {
         // Animation complete.
       });
    @@ -59,19 +59,21 @@ $( "#clickme" ).click(function() {
         

    With the element initially shown, we can hide it slowly with the first click:

    -

    - - - - -

    +
    + + + + +
    Figure 1 - Illustration of the toggle() effect when hiding the image
    +

    A second click will show the element once again:

    -

    - - - - -

    +
    + + + + +
    Figure 2 - Illustration of the toggle() effect when showing the image
    +

    The second version of the method accepts a Boolean parameter. If this parameter is true, then the matched elements are shown; if false, the elements are hidden. In essence, the statement:

    
    @@ -90,9 +92,9 @@ if ( display === true ) {
       
         Toggles all paragraphs.
         
         Toggle
    @@ -103,7 +105,7 @@ $( "button" ).click(function() {
       
         Animates all paragraphs to be shown if they are hidden and hidden if they are visible, completing the animation within 600 milliseconds.
         
    @@ -124,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 1d034d86..b42f2329 100644
    --- a/entries/toggleClass.xml
    +++ b/entries/toggleClass.xml
    @@ -1,67 +1,91 @@
     
    -
    -  .toggleClass()
    -  
    -    1.0
    -    
    -      One or more class names (separated by spaces) to be toggled for each element in the matched set.
    -    
    -  
    -  
    -    1.3
    -    
    -      One or more class names (separated by spaces) to be toggled for each element in the matched set.
    -    
    -    
    -      A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
    -    
    -  
    -  
    -    1.4
    -    
    -      A boolean value to determine whether the class should be added or removed.
    -    
    -  
    -  
    -    1.4
    -    
    -      
    -      
    -      
    -        
    -      A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.
    -    
    -    
    -      A boolean value to determine whether the class should be added or removed.
    -    
    -  
    -  Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
    -  
    -    

    This method takes one or more class names as its parameter. In the first version, if an element in the matched set of elements already has the class, then it is removed; if an element does not have the class, then it is added. For example, we can apply .toggleClass() to a simple <div>:

    -
    
    +
    +  
    +    .toggleClass()
    +    
    +      1.0
    +      
    +        One or more classes (separated by spaces) to be toggled for each element in the matched set.
    +      
    +    
    +    
    +      1.3
    +      
    +        One or more classes (separated by spaces) to be toggled for each element in the matched set.
    +      
    +      
    +        A boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
    +      
    +    
    +    
    +      3.3
    +      
    +        An array of classes to be toggled for each element in the matched set.
    +      
    +    
    +    
    +      3.3
    +      
    +        An array of classes to be toggled for each element in the matched set.
    +      
    +      
    +        A boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
    +      
    +    
    +    
    +      1.4
    +      
    +        
    +        
    +        
    +        
    +        A function returning one or more space-separated class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.
    +      
    +      
    +        A boolean value to determine whether the class should be added or removed.
    +      
    +    
    +    
    +      3.3
    +      
    +        
    +        
    +        
    +        
    +        
    +        A function returning one or more space-separated class names or an array of class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.
    +      
    +      
    +        A boolean value to determine whether the class should be added or removed.
    +      
    +    
    +    Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
    +    
    +      

    This method takes one or more classes as its parameter. In the first version, if an element in the matched set of elements already has the class, then it is removed; if an element does not have the class, then it is added. For example, we can apply .toggleClass() to a simple <div>:

    +
    
     <div class="tumble">Some text.</div>
    -    
    -

    The first time we apply $( "div.tumble" ).toggleClass( "bounce" ), we get the following:

    -
    
    +      
    +

    The first time we apply $( "div.tumble" ).toggleClass( "bounce" ), we get the following:

    +
    
     <div class="tumble bounce">Some text.</div>
    -    
    -

    The second time we apply $( "div.tumble" ).toggleClass( "bounce" ), the <div> class is returned to the single tumble value:

    -
    <div class="tumble">Some text.</div>
    -

    Applying .toggleClass( "bounce spin" ) to the same <div> alternates between <div class="tumble bounce spin"> and <div class="tumble">.

    -

    The second version of .toggleClass() uses the second parameter for determining whether the class should be added or removed. If this parameter's value is true, then the class is added; if false, the class is removed. In essence, the statement:

    -
    
    +      
    +

    The second time we apply $( "div.tumble" ).toggleClass( "bounce" ), the <div> class is returned to the single tumble value:

    +
    <div class="tumble">Some text.</div>
    +

    Applying .toggleClass( "bounce spin" ) to the same <div> alternates between <div class="tumble bounce spin"> and <div class="tumble">.

    +

    The second version of .toggleClass() uses the second parameter for determining whether the class should be added or removed. If this parameter's value is true, then the class is added; if false, the class is removed. In essence, the statement:

    +
    
     $( "#foo" ).toggleClass( className, addOrRemove );
    -    
    -

    is equivalent to:

    -
    
    +      
    +

    is equivalent to:

    +
    
     if ( addOrRemove ) {
       $( "#foo" ).addClass( className );
     } else {
       $( "#foo" ).removeClass( className );
     }
    -    
    -

    As of jQuery 1.4, if no arguments are passed to .toggleClass(), all class names on the element the first time .toggleClass() is called will be toggled. Also as of jQuery 1.4, the class name to be toggled can be determined by passing in a function.

    -
    
    +      
    +

    As of jQuery 1.4, if no arguments are passed to .toggleClass(), all classes on the element the first time .toggleClass() is called will be toggled. Also as of jQuery 1.4, the class name to be toggled can be determined by passing in a function.

    +
    
     $( "div.foo" ).toggleClass(function() {
       if ( $( this ).parent().is( ".bar" ) ) {
         return "happy";
    @@ -69,17 +93,17 @@ $( "div.foo" ).toggleClass(function() {
         return "sad";
       }
     });
    -
    -

    This example will toggle the happy class for <div class="foo"> elements if their parent element has a class of bar; otherwise, it will toggle the sad class.

    -
    - - Toggle the class 'highlight' when a paragraph is clicked. -
    +

    This example will toggle the happy class for <div class="foo"> elements if their parent element has a class of bar; otherwise, it will toggle the sad class.

    +
    + + Toggle the class 'highlight' when a paragraph is clicked. + - - Click to toggle

    highlight

    on these

    paragraphs

    ]]> -
    - - Add the "highlight" class to the clicked paragraph on every third click of that paragraph, remove it every first and second click. - + + Add the "highlight" class to the clicked paragraph on every third click of that paragraph, remove it every first and second click. + - - Click to toggle (clicks: 0)

    highlight (clicks: 0)

    on these (clicks: 0)

    paragraphs (clicks: 0)

    ]]> -
    - - Toggle the class name(s) indicated on the buttons for each div. - - + + Toggle the class name(s) indicated on the buttons for each div. + div { float: left; width: 100px; margin: 1em 1em 0 0; - padding=left: 3px; + padding-left: 3px; border: 1px solid #abc; } div.a { @@ -156,7 +179,7 @@ $( "p" ).each(function() { background-color: cornsilk; } ]]> - @@ -171,7 +194,7 @@ $( "p" ).each(function() {
    ]]> - -
    - - - - - - -
    +
    + + + + + + + + + + + + 1.4 + + A boolean value to determine whether the class should be added or removed. + + + +
    This signature (only!) is deprecated as of jQuery 3.0.
    +
    + +
    + diff --git a/entries/trigger.xml b/entries/trigger.xml index c840b058..caff8cb8 100644 --- a/entries/trigger.xml +++ b/entries/trigger.xml @@ -46,18 +46,19 @@ $( "#foo").trigger( "custom", [ "Custom", "Event" ] );

    The .trigger() method can be used on jQuery collections that wrap plain JavaScript objects similar to a pub/sub mechanism; any event handlers bound to the object will be called when the event is triggered.

    Note: For both plain objects and DOM objects other than window, if a triggered event name matches the name of a property on the object, jQuery will attempt to invoke the property as a method if no event handler calls event.preventDefault(). If this behavior is not desired, use .triggerHandler() instead.
    Note: As with .triggerHandler(), when calling .trigger() with an event name matches the name of a property on the object, prefixed by on (e.g. triggering click on window that has a non null onclick method), jQuery will attempt to invoke that property as a method.
    +
    Note: When triggering with a plain object that is not array-like but still contains a length property, you should pass the object in an array (e.g. [ { length: 1 } ]).
    Clicks to button #2 also trigger a click for button #1. To submit the first form without using the submit() function, try: To submit the first form without using the submit() function, try: To pass arbitrary data to an event: diff --git a/entries/triggerHandler.xml b/entries/triggerHandler.xml index d72516a8..83b2a576 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. Focused!" ).appendTo( "body" ).fadeOut( 1000 ); -}); +} ); ]]> .trigger( "focus" ) diff --git a/entries/unbind.xml b/entries/unbind.xml index e6be9a13..6a85004e 100644 --- a/entries/unbind.xml +++ b/entries/unbind.xml @@ -1,11 +1,11 @@ - + .unbind() Remove a previously-attached event handler from the elements. 1.0 - A string containing a JavaScript event type, such as click or submit. + A string containing one or more DOM event types, such as "click" or "submit," or custom event names. The function that is to be no longer executed. @@ -15,7 +15,7 @@ 1.4.3 - A string containing a JavaScript event type, such as click or submit. + A string containing one or more DOM event types, such as "click" or "submit," or custom event names. Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). @@ -31,7 +31,8 @@ 1.0 -

    Event handlers attached with .bind() can be removed with .unbind(). (As of jQuery 1.7, the .on() and .off() methods are preferred to attach and remove event handlers on elements.) In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:

    +

    As of jQuery 3.0, .unbind() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

    +

    Event handlers attached with .bind() can be removed with .unbind(). In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:

    
     $( "#foo" ).unbind();
         
    @@ -101,12 +102,12 @@ This example is also an illustration of a closure. Since the handler refers to t function aClick() { $( "div" ).show().fadeOut( "slow" ); } -$( "#bind" ).click(function() { +$( "#bind" ).on( "click", function() { $( "#theone" ) .bind( "click", aClick ) .text( "Can Click!" ); }); -$( "#unbind" ).click(function() { +$( "#unbind" ).on( "click", function() { $( "#theone" ) .unbind( "click", aClick ) .text( "Does nothing..." ); @@ -155,4 +156,5 @@ $( "p" ).unbind( "click", foo ); // ... foo will no longer be called. +
    diff --git a/entries/undelegate.xml b/entries/undelegate.xml index 842a504a..f3a98596 100644 --- a/entries/undelegate.xml +++ b/entries/undelegate.xml @@ -1,5 +1,5 @@ - + .undelegate() Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. @@ -43,7 +43,8 @@ -

    The .undelegate() method is a way of removing event handlers that have been bound using .delegate(). As of jQuery 1.7, the .on() and .off() methods are preferred for attaching and removing event handlers.

    +

    As of jQuery 3.0, .undelegate() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

    +

    The .undelegate() method is a way of removing event handlers that have been bound using .delegate().

    Can bind and unbind events to the colored button. @@ -51,12 +52,12 @@ function aClick() { $( "div" ).show().fadeOut( "slow" ); } -$( "#bind" ).click(function() { +$( "#bind" ).on( "click", function() { $( "body" ) .delegate( "#theone", "click", aClick ) .find( "#theone" ).text( "Can Click!" ); }); -$( "#unbind" ).click(function() { +$( "#unbind" ).on( "click", function() { $( "body" ) .undelegate( "#theone", "click", aClick ) .find( "#theone" ).text( "Does nothing..." ); @@ -124,4 +125,5 @@ $( "form" ).undelegate( ".whatever" ); +
    diff --git a/entries/uniqueSort.xml b/entries/uniqueSort.xml new file mode 100644 index 00000000..999f15b0 --- /dev/null +++ b/entries/uniqueSort.xml @@ -0,0 +1,112 @@ + + + .uniqueSort() + + 3.7 + + Sorts a jQuery object of DOM elements, in place, with the duplicates removed. Note that this only works on jQuery objects consisting of DOM elements, not strings or numbers. + +

    The .uniqueSort() function searches through a jQuery object, sorting it in document order, and removing any duplicate nodes. A node is considered a duplicate if it is the exact same node as one already in the jQuery object; two different nodes with identical attributes are not considered to be duplicates. This function only works on jQuery objects consisting of DOM elements.

    +
    + + Removes any duplicate elements from the jQuery object of divs. + + + There are 6 divs in this document. +
    +
    +
    +
    +
    +]]> +
    + + Locate all the divs preceding the last item and wrap them with a div with class wrapper - with or without .uniqueSort(). + " ); + +$( "#container-2" ) + .find( ".item" ) + .last() + .prevAll() + .uniqueSort() + .wrapAll( "
    " ); +]]>
    + + +
    1
    +
    2
    +
    3
    + + +
    +
    1
    +
    2
    +
    3
    +
    +]]> +
    + + +
    diff --git a/entries/unload-shorthand.xml b/entries/unload-shorthand.xml new file mode 100644 index 00000000..693768ec --- /dev/null +++ b/entries/unload-shorthand.xml @@ -0,0 +1,37 @@ + + + .unload() + Bind an event handler to the "unload" 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 .unload( handler ) or .unload( eventData, handler ), use .on( "unload", handler ) or .on( "unload", eventData, handler ), respectively.

    +

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

    +
    +
    + + + + + +
    diff --git a/entries/unload.xml b/entries/unload.xml index e33dc639..05d1c27a 100644 --- a/entries/unload.xml +++ b/entries/unload.xml @@ -1,15 +1,15 @@ - - .unload() + +Bind an event handler to the "unload" event, or trigger that event on an element. + + + unload event + Bind an event handler to the "unload" event. - 1.0 - - A function to execute when the event is triggered. - + 1.7 + + The string "unload". - - - 1.4.3 A plain object of data that will be passed to the event handler. @@ -18,31 +18,49 @@ - Bind an event handler to the "unload" JavaScript event. -

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

    +
    +

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

    +

    The unload event is sent to the window element when the user navigates away from the page. This could mean one of many things. The user could have clicked on a link to leave the page, or typed in a new URL in the address bar. The forward and back buttons will trigger the event. Closing the browser window will cause the event to be triggered. Even a page reload will first create an unload event.

    -

    The exact handling of the unload event has varied from version to version of browsers. For example, some versions of Firefox trigger the event when a link is followed, but not when the window is closed. In practical usage, behavior should be tested on all supported browsers, and contrasted with the proprietary beforeunload event.

    +

    The exact handling of the unload event has varied from version to version of browsers. For example, some versions of Firefox trigger the event when a link is followed, but not when the window is closed. In practical usage, behavior should be tested on all supported browsers and contrasted with the similar beforeunload event.

    Any unload event handler should be bound to the window object:

    
    -$( window ).unload(function() {
    -  return "Handler for .unload() called.";
    -});
    +$( window ).on( "unload", function() {
    +  return "Handler for `unload` called.";
    +} );
         

    This event is available so that scripts can perform cleanup when the user leaves the page. Most browsers will ignore calls to alert(), confirm() and prompt() inside the event handler. The string you return may be used in a confirmation dialog, but not all browsers support this. It is not possible to cancel the unload event with .preventDefault().

    To display an alert when a page is unloaded: - - + +
    + + + 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 d966952c..b2dde604 100644 --- a/entries/unwrap.xml +++ b/entries/unwrap.xml @@ -4,15 +4,21 @@ 1.4 + + 3.0 + + A selector to check the parent element against. If an element's parent does not match the selector, the element won't be unwrapped. + + Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. -

    The .unwrap() method removes the element's parent. This is effectively the inverse of the .wrap() method. The matched elements (and their siblings, if any) replace their parents within the DOM structure.

    +

    The .unwrap() method removes the element's parent and returns the unwrapped content. This is effectively the inverse of the .wrap() method. The matched elements (and their siblings, if any) replace their parents within the DOM structure.

    Wrap/unwrap a div around each of the paragraphs. Get the current value of the first element in the set of matched elements. -

    The .val() method is primarily used to get the values of form elements such as input, select and textarea. In the case of select elements, it returns null when no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because the multiple attribute is present.

    -

    For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:

    +

    The .val() method is primarily used to get the values of form elements such as input, select and textarea. When called on an empty collection, it returns undefined.

    +

    When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), .val() returns an array containing the value of each selected option. As of jQuery 3.0, if no options are selected, it returns an empty array; prior to jQuery 3.0, it returns null.

    +

    For selects, checkboxes and radio buttons, you can use :checked to select the right elements. For example:

    
    -// Get the value from a dropdown select
    -$( "select.foo option:selected").val();
    +// Get the value from the selected option in a dropdown
    +$( "select#foo option:checked" ).val();
     
    -// Get the value from a dropdown select even easier
    -$( "select.foo" ).val();
    +// Get the value from a dropdown select directly
    +$( "select#foo" ).val();
     
     // Get the value from a checked checkbox
    -$( "input:checkbox:checked" ).val();
    +$( "input[type=checkbox][name=bar]:checked" ).val();
     
     // Get the value from a set of radio buttons
    -$( "input:radio[name=bar]:checked" ).val();
    +$( "input[type=radio][name=baz]:checked" ).val();
           
    -

    Note: At present, using .val() on textarea elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:

    +

    Note: At present, using .val() on <textarea> elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR, however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:

    
     $.valHooks.textarea = {
    @@ -43,11 +44,13 @@ $.valHooks.textarea = {
     function displayVals() {
       var singleValues = $( "#single" ).val();
       var multipleValues = $( "#multiple" ).val() || [];
    +  // When using jQuery 3:
    +  // var multipleValues = $( "#multiple" ).val();
       $( "p" ).html( "Single: " + singleValues +
         " Multiple: " + multipleValues.join( ", " ) );
     }
     
    -$( "select" ).change( displayVals );
    +$( "select" ).on( "change", displayVals );
     displayVals();
     ]]>
           Find the value of an input box.
           
           1.4
           
             
    -             
    -                 
    +        
    +        
             A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
           
         
         Set the value of each element in the set of matched elements.
         
           

    This method is typically used to set the values of form fields.

    -

    Passing an array of element values allows matching <input type="checkbox">, <input type="radio"> and <option>s inside of n <select multiple="multiple"> to be selected. In the case of <input type="radio">s that are part of a radio group and <select multiple="multiple"> the other elements will be deselected.

    -

    The .val() method allows us to set the value by passing in a function. As of jQuery 1.4, the function is passed two arguments, the current element's index and its current value:

    +

    val() allows you to pass an array of element values. This is useful when working on a jQuery object containing elements like <input type="checkbox">, <input type="radio">, and <option>s inside of a <select>. In this case, the inputs and the options having a value that matches one of the elements of the array will be checked or selected while those having a value that doesn't match one of the elements of the array will be unchecked or unselected, depending on the type. In the case of <input type="radio">s that are part of a radio group and <select>s, any previously selected element will be deselected.

    +

    Setting values using this method (or using the native value property) does not cause the dispatch of the change event. For this reason, the relevant event handlers will not be executed. If you want to execute them, you should call .trigger( "change" ) after setting the value.

    +

    The .val() method allows setting the value by passing in a function. As of jQuery 1.4, the function is passed two arguments, the current element's index and its current value:

    
    -$( "input:text.items" ).val(function( index, value ) {
    -  return value + " " + this.className;
    +$( "input[type=text].tags" ).val(function( index, value ) {
    +  return value.trim();
     });
           
    -

    This example appends the string " items" to the text inputs' values.

    +

    This example removes leading and trailing whitespace from the values of text inputs with a "tags" class.

    Set the value of an input box. Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.

    Elements with visibility: hidden or opacity: 0 are considered visible, since they still consume space in the layout.

    Elements that are not in a document are considered hidden; jQuery does not have a way to know if they will be visible when appended to a document since it depends on the applicable styles.

    +

    This selector is the opposite of the :hidden selector. So, every element selected by :visible isn't selected by :hidden and vice versa.

    All option elements are considered hidden, regardless of their selected state.

    During animations that hide an element, the element is considered visible until the end of the animation. During animations to show an element, the element is considered visible at the start at the animation.

    -

    How :visible is calculated was changed in jQuery 1.3.2. The release notes outline the changes in more detail.

    +

    How :visible is calculated was changed in jQuery 1.3.2. The release notes outline the changes in more detail.

    +

    jQuery 3 slightly modifies the meaning of :visible (and therefore of :hidden). Starting with this version, elements will be considered :visible if they have any layout boxes, including those of zero width and/or height. For example, br elements and inline elements with no content will be selected by the :visible selector.

    Make all visible divs turn yellow on click. Get the current computed width for the first element in the set of matched elements. -

    The difference between .css(width) and .width() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .width() method is recommended when an element's width needs to be used in a mathematical calculation.

    -

    +

    The difference between .css( "width" ) and .width() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .width() method is recommended when an element's width needs to be used in a mathematical calculation.

    +
    -

    +
    Figure 1 - Illustration of the measured width
    +

    This method is also able to find the width of the window and document.

    
     // Returns width of browser viewport
    @@ -25,23 +26,23 @@ $( document ).width();
             

    Note: Although style and script tags will report a value for .width() or height() when absolutely positioned and given display:block, it is strongly discouraged to call those methods on these tags. In addition to being a bad practice, the results may also prove unreliable.

    - - + + Show various widths. Note the values are from the iframe so might be smaller than you expected. The yellow highlight shows the iframe body. 1.4 - A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. - + A callback function returning the HTML content or jQuery object to wrap around all the matched elements. Within the function, this refers to the first element in the set. Prior to jQuery 3.0, the callback was incorrectly called for every element in the set and received the index position of the element in the set as an argument. diff --git a/entries2html.xsl b/entries2html.xsl index fe2dc09b..a1a19982 100755 --- a/entries2html.xsl +++ b/entries2html.xsl @@ -12,7 +12,7 @@ <meta charset="utf-8"> <title> demo</title> <style> </style> - <script src="https://code.jquery.com/jquery-1.10.2.js"></script> + <script src="https://code.jquery.com/jquery-3.7.1.js"></script> <script> </script> diff --git a/includes/complete-argument.xml b/includes/complete-argument.xml index 042fdf45..4ef06fa3 100644 --- a/includes/complete-argument.xml +++ b/includes/complete-argument.xml @@ -1,4 +1,4 @@ - A function to call once the animation is complete. + A function to call once the animation is complete, called once per matched element. diff --git a/includes/duration-argument.xml b/includes/duration-argument.xml index 1a1c5c5e..8fcfb7f3 100644 --- a/includes/duration-argument.xml +++ b/includes/duration-argument.xml @@ -1,6 +1,6 @@ - A string or number determining how long the animation will run. - - + A string or number determining how long the animation will run. + + diff --git a/includes/easing-argument.xml b/includes/easing-argument.xml index b6483551..127057af 100644 --- a/includes/easing-argument.xml +++ b/includes/easing-argument.xml @@ -1,4 +1,4 @@ - A string indicating which easing function to use for the transition. + A string indicating which easing function to use for the transition. diff --git a/includes/options-argument.xml b/includes/options-argument.xml index f62a8585..cacb3286 100644 --- a/includes/options-argument.xml +++ b/includes/options-argument.xml @@ -1,81 +1,81 @@ - A map of additional options to pass to the method. - - A string or number determining how long the animation will run. - - - - - A string indicating which easing function to use for the transition. - - - A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it. - - - - - An object containing one or more of the CSS properties defined by the properties argument and their corresponding easing functions. - + A map of additional options to pass to the method. + + A string or number determining how long the animation will run. + + + + + A string indicating which easing function to use for the transition. + + + A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it. + + + + + An object containing one or more of the CSS properties defined by the properties argument and their corresponding easing functions. + - - A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set. - - The numeric value of the property being animated at each step - - - An object of properties related to the animation and the element being animated. For information about the tween object and its properties, see jQuery.Tween - - + + A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set. + + The numeric value of the property being animated at each step + + + An object of properties related to the animation and the element being animated. For information about the tween object and its properties, see jQuery.Tween + + - - A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. - - An enhanced Promise object with additional properties for the animation - - - A number from 0 to 1 indicating the progress of the animation - - - A number indicating the remaining number of milliseconds until the scheduled end of the animation - - - - A function to call once the animation is complete. - - - - A function to call when the animation begins. - - An enhanced Promise object with additional properties for the animation - - - - A function to be called when the animation completes (its Promise object is resolved). - - An enhanced Promise object with additional properties for the animation - - - Indicates whether the animation jumped to the end - - - - A function to be called when the animation fails to complete (its Promise object is rejected). - - An enhanced Promise object with additional properties for the animation - - - Indicates whether the animation jumped to the end - - - - A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected). - - An enhanced Promise object with additional properties for the animation - - - Indicates whether the animation jumped to the end - - + + A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. + + An enhanced Promise object with additional properties for the animation + + + A number from 0 to 1 indicating the progress of the animation + + + A number indicating the remaining number of milliseconds until the scheduled end of the animation + + + + A function that is called once the animation on an element is complete. + + + + A function to call when the animation on an element begins. + + An enhanced Promise object with additional properties for the animation + + + + A function to be called when the animation on an element completes (its Promise object is resolved). + + An enhanced Promise object with additional properties for the animation + + + Indicates whether the animation jumped to the end + + + + A function to be called when the animation on an element fails to complete (its Promise object is rejected). + + An enhanced Promise object with additional properties for the animation + + + Indicates whether the animation jumped to the end + + + + A function to be called when the animation on an element completes or stops without completing (its Promise object is either resolved or rejected). + + An enhanced Promise object with additional properties for the animation + + + Indicates whether the animation jumped to the end + + diff --git a/notes.xsl b/notes.xsl index d62bda2c..6963dad2 100644 --- a/notes.xsl +++ b/notes.xsl @@ -2,7 +2,10 @@ - undefined is not recognised as a data value. Calls such as ( , undefined ) will return the corresponding data for "name", and is therefore the same as ( ). + undefined is not recognized as a data value. Calls such as ( , undefined ) will return the jQuery object that it was called on, allowing for chaining. + + + undefined is not recognized as a data value. Calls such as ( , undefined ) will return the corresponding data for "name", and is therefore the same as ( ). The number returned by dimensions-related APIs, including , may be fractional in some cases. Code should not assume it is an integer. Also, dimensions may be incorrect when the page is zoomed by the user; browsers do not expose an API to detect this condition. @@ -14,10 +17,10 @@ Selected elements are in the order of their appearance in the document. - Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint. + Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint. - - The value reported by is not guaranteed to be accurate when the element's parent is hidden. To get an accurate value, you should show the parent first, before using . + + The value reported by is not guaranteed to be accurate when the element or its parent is hidden. To get an accurate value, ensure the element is visible before using . jQuery will attempt to temporarily show and then re-hide an element in order to measure its dimensions, but this is unreliable and (even when accurate) can significantly impact page performance. This show-and-rehide measurement feature may be removed in a future version of jQuery. Because is a jQuery extension and not part of the CSS specification, queries using cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. To achieve the best performance when using to select elements, first select the elements using a pure CSS selector, then use .filter(""). @@ -41,16 +44,16 @@ The method removes all data and event handlers associated with the removed nodes. - Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. + Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. Script and JSONP requests are not subject to the same origin policy restrictions. - If a request with returns an error code, it will fail silently unless the script has also called the global .ajaxError() method. Alternatively, as of jQuery 1.5, the .error() method of the jqXHR object returned by is also available for error handling. + If a request with returns an error code, it will fail silently unless the script has also called the global ajaxError event. Alternatively, as of jQuery 1.5, the .error() method of the jqXHR object returned by is also available for error handling. - If $.ajax() or $.ajaxSetup() is called with the global option set to false, the method will not fire. + If $.ajax() or $.ajaxSetup() is called with the global option set to false, the event will not fire. If is called on an unordered list (<ul>) and its <li> elements have position (relative, absolute, or fixed), the effect may not work properly in IE6 through at least IE9 unless the <ul> has "layout." To remedy the problem, add the position: relative; and zoom: 1; CSS declarations to the ul. @@ -61,6 +64,12 @@ Using this selector heavily can have performance implications, as it may force the browser to re-render the page before it can determine visibility. Tracking the visibility of elements via other methods, using a class for example, can provide better performance. + + As of jQuery 1.9, all the handlers for the jQuery global Ajax events, including those added with .on( "", ... ), must be attached to document. + + + jQuery doesn't officially support SVG. Using jQuery methods on SVG documents, unless explicitly documented for that method, might cause unexpected behaviors. Examples of methods that support SVG as of jQuery 3.0 are addClass and removeClass. + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..0da24ae3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1292 @@ +{ + "name": "api.jquery.com", + "version": "3.3.10", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "api.jquery.com", + "version": "3.3.10", + "dependencies": { + "grunt": "1.6.1", + "grunt-jquery-content": "3.3.2" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/argparse/node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "node_modules/array-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/array-slice": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/async": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/cheerio": { + "version": "1.0.0-rc.12", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", + "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", + "dependencies": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "htmlparser2": "^8.0.1", + "parse5": "^7.0.0", + "parse5-htmlparser2-tree-adapter": "^7.0.0" + }, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "engines": { + "node": "*" + } + }, + "node_modules/detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eventemitter2": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=" + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dependencies": { + "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/findup-sync": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "dependencies": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/fined": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", + "dependencies": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/flagged-respawn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", + "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dependencies": { + "for-in": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/getobject": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", + "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", + "engines": { + "node": ">=10" + } + }, + "node_modules/gilded-wordpress": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/gilded-wordpress/-/gilded-wordpress-1.0.7.tgz", + "integrity": "sha512-w8g4jfs1TWywX2hZ4+LlzQoz2z/JRX/8S6OgelD3IUsNnGHxXQ1FgExoIqomwZVPAmxYs0vEu2BeA1Y4KciZlw==", + "dependencies": { + "async": "^0.9.0", + "wordpress": "^1.4.2" + } + }, + "node_modules/gilded-wordpress/node_modules/async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha512-l6ToIJIotphWahxxHyzK9bnLR6kM4jJIIgLShZeqLY7iboHoGkdgFl7W2/Ivi4SkMJYGKqW8vSuk0uKUj6qsSw==" + }, + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dependencies": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "dependencies": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.6.1.tgz", + "integrity": "sha512-/ABUy3gYWu5iBmrUSRBP97JLpQUm0GgVveDCp6t3yRNIoltIYw7rEj3g5y1o2PGPR2vfTRGa7WC/LZHLTXnEzA==", + "dependencies": { + "dateformat": "~4.6.2", + "eventemitter2": "~0.4.13", + "exit": "~0.1.2", + "findup-sync": "~5.0.0", + "glob": "~7.1.6", + "grunt-cli": "~1.4.3", + "grunt-known-options": "~2.0.0", + "grunt-legacy-log": "~3.0.0", + "grunt-legacy-util": "~2.0.1", + "iconv-lite": "~0.6.3", + "js-yaml": "~3.14.0", + "minimatch": "~3.0.4", + "nopt": "~3.0.6" + }, + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/grunt-check-modules": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/grunt-check-modules/-/grunt-check-modules-1.1.0.tgz", + "integrity": "sha1-fBZB28ZlSGdqbVl5Ga35C3s11kQ=", + "engines": { + "node": ">=0.6.0" + }, + "peerDependencies": { + "grunt": ">=0.4.0" + } + }, + "node_modules/grunt-jquery-content": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/grunt-jquery-content/-/grunt-jquery-content-3.3.2.tgz", + "integrity": "sha512-b6w8GBe022BG8O7BkhAKBFcBBAldoIiwAUZ2WI+A8HIouXy8XS8Cwp2RuUPEACg3g2/wHOarmjrsFKFPmmZ55Q==", + "dependencies": { + "cheerio": "^1.0.0-rc.12", + "gilded-wordpress": "1.0.7", + "grunt-check-modules": "^1.1.0", + "he": "^1.2.0", + "highlight.js": "^10.7.2", + "marked": "^4.0.0", + "which": "^4.0.0", + "wordpress": "^1.4.1" + } + }, + "node_modules/grunt-jquery-content/node_modules/isexe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "engines": { + "node": ">=16" + } + }, + "node_modules/grunt-jquery-content/node_modules/which": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^16.13.0 || >=18.0.0" + } + }, + "node_modules/grunt-legacy-log": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-3.0.0.tgz", + "integrity": "sha512-GHZQzZmhyq0u3hr7aHW4qUH0xDzwp2YXldLPZTCjlOeGscAOWWPftZG3XioW8MasGp+OBRIu39LFx14SLjXRcA==", + "dependencies": { + "colors": "~1.1.2", + "grunt-legacy-log-utils": "~2.1.0", + "hooker": "~0.2.3", + "lodash": "~4.17.19" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/grunt-legacy-log-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-2.1.0.tgz", + "integrity": "sha512-lwquaPXJtKQk0rUM1IQAop5noEpwFqOXasVoedLeNzaibf/OPWjKYvvdqnEHNmU+0T0CaReAXIbGo747ZD+Aaw==", + "dependencies": { + "chalk": "~4.1.0", + "lodash": "~4.17.19" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-util": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-2.0.1.tgz", + "integrity": "sha512-2bQiD4fzXqX8rhNdXkAywCadeqiPiay0oQny77wA2F3WF4grPJXCvAcyoWUJV+po/b15glGkxuSiQCK299UC2w==", + "dependencies": { + "async": "~3.2.0", + "exit": "~0.1.2", + "getobject": "~1.0.0", + "hooker": "~0.2.3", + "lodash": "~4.17.21", + "underscore.string": "~3.3.5", + "which": "~2.0.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-util/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/grunt/node_modules/grunt-cli": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", + "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", + "dependencies": { + "grunt-known-options": "~2.0.0", + "interpret": "~1.1.0", + "liftup": "~3.0.1", + "nopt": "~4.0.1", + "v8flags": "~3.2.0" + }, + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt/node_modules/grunt-cli/node_modules/nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dependencies": { + "abbrev": "1", + "osenv": "^0.1.4" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/grunt/node_modules/grunt-known-options": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", + "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/highlight.js": { + "version": "10.7.2", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.2.tgz", + "integrity": "sha512-oFLl873u4usRM9K63j4ME9u3etNF0PLiJhSQ8rdfuL51Wn3zkD6drf9ZW0dOzjnZI22YYG24z30JcmfCZjMgYg==", + "engines": { + "node": "*" + } + }, + "node_modules/homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dependencies": { + "parse-passwd": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/hooker": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", + "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", + "engines": { + "node": "*" + } + }, + "node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "node_modules/interpret": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=" + }, + "node_modules/is-absolute": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "dependencies": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-core-module": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", + "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-relative": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "dependencies": { + "is-unc-path": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-unc-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "dependencies": { + "unc-path-regex": "^0.1.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "node_modules/isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/liftup": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", + "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", + "dependencies": { + "extend": "^3.0.2", + "findup-sync": "^4.0.0", + "fined": "^1.2.0", + "flagged-respawn": "^1.0.1", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.1", + "rechoir": "^0.7.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/liftup/node_modules/findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dependencies": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/make-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "dependencies": { + "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/object.defaults": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "dependencies": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object.map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "dependencies": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "dependencies": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "node_modules/parse-filepath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "dependencies": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/parse5": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", + "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "dependencies": { + "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", + "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", + "dependencies": { + "domhandler": "^5.0.2", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "dependencies": { + "path-root-regex": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/rechoir": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.0.tgz", + "integrity": "sha512-ADsDEH2bvbjltXEP+hTIAmeFekTFK0V2BTxMkok6qILyAJEXV0AFfoWcAq4yfll5VdIMd/RVXq0lR+wQi5ZU3Q==", + "dependencies": { + "resolve": "^1.9.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "dependencies": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "node_modules/sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/underscore.string": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", + "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", + "dependencies": { + "sprintf-js": "^1.1.1", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "node_modules/v8flags": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "dependencies": { + "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/wordpress": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/wordpress/-/wordpress-1.4.2.tgz", + "integrity": "sha512-T+o+Af6pK7mhTz/rJEZk4PpSIyRMVhx6vZm6UsmrnlL8pVudhu1gWzn1n3wZXlcEZQz7I0AOkEvPQ5hu++L+qg==", + "dependencies": { + "xmlrpc": "1.3.2" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "node_modules/xmlbuilder": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz", + "integrity": "sha512-eKRAFz04jghooy8muekqzo8uCSVNeyRedbuJrp0fovbLIi7wlsYtdUn3vBAAPq2Y3/0xMz2WMEUQ8yhVVO9Stw==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/xmlrpc": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/xmlrpc/-/xmlrpc-1.3.2.tgz", + "integrity": "sha512-jQf5gbrP6wvzN71fgkcPPkF4bF/Wyovd7Xdff8d6/ihxYmgETQYSuTc+Hl+tsh/jmgPLro/Aro48LMFlIyEKKQ==", + "dependencies": { + "sax": "1.2.x", + "xmlbuilder": "8.2.x" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.0.0" + } + } + } +} diff --git a/package.json b/package.json index a2c4d4c8..c86c045c 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,12 @@ { "name": "api.jquery.com", - "title": "jQuery API Docs", - "description": "API reference documentation for the jQuery JavaScript Library.", - "version": "1.11.82", - "homepage": "https://github.com/jquery/api.jquery.com", - "author": { - "name": "jQuery Foundation and other contributors" + "version": "3.3.10", + "private": true, + "scripts": { + "test": "grunt lint" }, - "repository": { - "type": "git", - "url": "git://github.com/jquery/api.jquery.com.git" - }, - "bugs": { - "url": "https://github.com/jquery/api.jquery.com/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/jquery/api.jquery.com/blob/master/LICENSE.txt" - } - ], "dependencies": { - "grunt": "0.4.5", - "grunt-jquery-content": "2.0.0" + "grunt": "1.6.1", + "grunt-jquery-content": "3.3.2" } } diff --git a/pages/Ajax_Events.html b/pages/Ajax_Events.html index 9ba25ff7..6b1249be 100644 --- a/pages/Ajax_Events.html +++ b/pages/Ajax_Events.html @@ -19,9 +19,9 @@

    Local Events

    Global Events

    These events are triggered on the document, calling any handlers which may be listening. You can listen for these events like so:

    -
     $(document).bind("ajaxSend", function(){
    +
     $(document).on("ajaxSend", function(){
        $("#loading").show();
    - }).bind("ajaxComplete", function(){
    + }).on("ajaxComplete", function(){
        $("#loading").hide();
      });
     
    @@ -33,7 +33,7 @@

    Global Events

    });

    Events

    -

    This is the full list of Ajax events , and in the order in which they are triggered. The indented events are triggered for each and every Ajax request (unless a global option has been set). The ajaxStart and ajaxStop events are events that relate to all Ajax requests together. +

    This is the full list of Ajax events, and in the order in which they are triggered. The indented events are triggered for each and every Ajax request (unless a global option has been set). The ajaxStart and ajaxStop events are events that relate to all Ajax requests together.

    • ajaxStart (Global Event)
      This event is triggered if an Ajax request is started and no other Ajax requests are currently running. diff --git a/pages/Types.html b/pages/Types.html index 422f6bd6..16a3a7c1 100644 --- a/pages/Types.html +++ b/pages/Types.html @@ -1,6 +1,6 @@ -

      JavaScript provides several built-in datatypes. In addition to those, this page documents virtual types like Selectors, enhanced pseudo-types like Events and all and everything you wanted to know about Functions. +

      This page documents data types appearing in jQuery function signatures, whether defined by JavaScript itself or further restricted by jQuery. Unless explicitly stated otherwise, jQuery functions require primitive values where applicable, and do not accept their Object-wrapped forms. If you want to study these concepts in depth, take a look at MDN.

      -

      You should be able to try out most of the examples below by just copying them to your browser's JavaScript Console (Chrome, Safari with Develop menu activated, IE 8+) or Firebug console (Firefox). +

      You should be able to try out most of the examples below by just copying them to your browser's JavaScript Console.

      Whenever an example mentions that a type defaults to a boolean value, the result is good to know when using that type in a boolean context:

      @@ -73,6 +73,7 @@
    • Array<Type> Notation
    +
  • Array-Like Object
  • PlainObject
  • Date
  • Function @@ -84,12 +85,15 @@
  • Proxy Pattern
  • +
  • Error
  • Selector
  • Event
  • Element
  • +
  • Text
  • jQuery
  • XMLHttpRequest
  • jqXHR
  • +
  • Thenable
  • Deferred Object
  • Promise Object
  • Callbacks Object
  • @@ -97,12 +101,12 @@
  • Qunit's Assert Object
  • -

    Anything

    +

    Anything

    The Anything virtual type is used in jQuery documentation to indicate that any type can be used or should be expected.

    -

    String

    -

    A string in JavaScript is an immutable object that contains none, one or many characters. +

    String

    +

    A string in JavaScript is an immutable primitive value that contains none, one or many characters.

    "I'm a String in JavaScript!"
     'So am I!'
    @@ -111,14 +115,14 @@ 

    String

    typeof "some string"; // "string"
     
    -

    Quoting

    +

    Quoting

    A string can be defined using single or double quotes. You can nest single quotes inside of double quotes, and the other way around. To mix double quotes with double quotes (or single with single), the nested ones have to be escaped with a backslash.

    "You make 'me' sad."
     'That\'s "cranking" good fun!'
     "<a href=\"home\">Home</a>"
     
    -

    Built-in Methods

    +

    Built-in Methods

    A string in JavaScript has some built-in methods to manipulate the string, though the result is always a new string - or something else, eg. split returns an array.

    "hello".charAt( 0 ) // "h"
    @@ -127,13 +131,13 @@ 

    Built-in Methods

    "hello".replace( /e|o/g, "x" ) // "hxllx" "1,2,3".split( "," ) // [ "1", "2", "3" ]
    -

    Length Property

    +

    Length Property

    All strings have a length property.

    "Hello".length // 5
     "".length // 0
     
    -

    Boolean Default

    +

    Boolean Default

    An empty string defaults to false:

    !"" // true
    @@ -143,9 +147,9 @@ 

    Boolean Default

    !new Boolean( false ) // false
    -

    htmlString

    +

    htmlString

    A string is designated htmlString in jQuery documentation when it is used to represent one or more DOM elements, typically to be created and inserted in the document. When passed as an argument of the jQuery() function, the string is identified as HTML if it starts with <tag ... >) and is parsed as such until the final > character. Prior to jQuery 1.9, a string was considered to be HTML if it contained <tag ... > anywhere within the string.

    -

    When a string as passed as an argument to a manipulation method such as .append(), it is always considered to be HTML since jQuery's other common interpretation of a string (CSS selectors) does not apply in those contexts.

    +

    When a string is passed as an argument to a manipulation method such as .append(), it is always considered to be HTML since jQuery's other common interpretation of a string (CSS selectors) does not apply in those contexts.

    For explicit parsing of a string to HTML, the $.parseHTML() method is available as of jQuery 1.8.

    // Appends hello:
     $( "hello" ).appendTo( "body" );
    @@ -162,8 +166,8 @@ 

    htmlString

    // Appends hellowaitbye: $( "hellowaitbye" ).appendTo( "body" );
    -

    Number

    -

    Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable, just as strings. All operators common in c-based languages are available to work with numbers (+, -, *, /, %, =, +=, -=, *=, /=, ++, --). +

    Number

    +

    Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable primitive values, just like strings. All operators common in c-based languages are available to work with numbers (+, -, *, /, %, =, +=, -=, *=, /=, ++, --).

    12
     3.543
    @@ -173,7 +177,7 @@ 

    Number

    typeof 12 // "number"
     typeof 3.543 // "number"
     
    -

    Boolean Default

    +

    Boolean Default

    If a number is zero, it defaults to false:

    !0 // true
    @@ -185,15 +189,13 @@ 

    Boolean Default

    0.1 + 0.2 // 0.30000000000000004
     
    -


    -

    -

    Math

    +

    Math

    JavaScript provides utilities to work with numbers in the Math object:

    Math.PI // 3.141592653589793
     Math.cos( Math.PI ) // -1
     
    -

    Parsing Numbers

    +

    Parsing Numbers

    parseInt and parseFloat help parsing strings into numbers. Both do some implicit conversion if the base isn't specified:

    parseInt( "123" ) = 123 // (implicit decimal)
    @@ -203,8 +205,8 @@ 

    Parsing Numbers

    parseInt( "11", 2 ) = 3 // (explicit binary) parseFloat( "10.10" ) = 10.1
    -

    Numbers to Strings

    -

    When appending numbers to string, the result is always a string. The operator is the same, so be careful: If you want to add numbers and then append them to a string, put parentheses around them: +

    Numbers to Strings

    +

    When appending numbers to string, the result is always a string. The operator is the same, so be careful: If you want to add numbers and then append them to a string, put parentheses around the numbers:

    "" + 1 + 2; // "12"
     "" + ( 1 + 2 ); // "3"
    @@ -216,7 +218,7 @@ 

    Numbers to Strings

    String( 1 ) + String( 2 ); // "12"
     String( 1 + 2 ); // "3"
     
    -

    NaN and Infinity

    +

    NaN and Infinity

    Parsing something that isn't a number results in NaN. isNaN helps to detect those cases:

    parseInt( "hello", 10 ) // NaN
    @@ -233,27 +235,25 @@ 

    NaN and Infinity

    Note that NaN compares in a strange way:

    -
    NaN == NaN // false (!)
    +
    NaN === NaN // false (!)
     

    But:

    -
    Infinity == Infinity // true
    +
    Infinity === Infinity // true
     
    -

    Integer

    +

    Integer

    An integer is a plain Number type, but whenever explicitly mentioned, indicates that a non-floating-point number is expected.

    -

    Float

    +

    Float

    A float is a plain Number type, just as Integer, but whenever explicitly mentioned, indicates that a floating-point number is expected.

    -


    -

    -

    Boolean

    +

    Boolean

    A boolean in JavaScript can be either true or false:

    if ( true ) console.log( "always!" );
     if ( false ) console.log( "never!" );
     
    -

    Object

    +

    Object

    Everything in JavaScript is an object, though some are more objective (haha). The easiest way to create an object is the object literal:

    var x = {};
    @@ -266,7 +266,7 @@ 

    Object

    typeof {} // "object"
     
    -

    Dot Notation

    +

    Dot Notation

    You can write and read properties of an object using the dot notation:

    y.name // "Pete"
    @@ -274,7 +274,7 @@ 

    Dot Notation

    x.name = y.name + " Pan" // "Pete Pan" x.age = y.age + 1 // 16
    -

    Array Notation

    +

    Array Notation

    Or you write and read properties using the array notation, which allows you to dynamically choose the property:

    var operations = {
    @@ -285,7 +285,7 @@ 

    Array Notation

    operations[ operation ] // "++" operations[ "multiply" ] = "*"; // "*"
    -

    Iteration

    +

    Iteration

    Iterating over objects is easy with the for-in-loop:

    var obj = {
    @@ -296,7 +296,7 @@ 

    Iteration

    alert( "key is " + [ key ] + ", value is " + obj[ key ] ); }
    -

    Note that for-in-loop can be spoiled by extending Object.prototype (see Object.prototype is verboten) so take care when using other libraries. +

    Note that for-in-loop can be spoiled by extending Object.prototype (see Object.prototype is verboten) so take care when using other libraries.

    jQuery provides a generic each function to iterate over properties of objects, as well as elements of arrays:

    @@ -307,19 +307,19 @@

    Iteration

    The drawback is that the callback is called in the context of each value and you therefore lose the context of your own object if applicable. More on this below at Functions.

    -

    Boolean default

    +

    Boolean default

    An object, no matter if it has properties or not, never defaults to false:

    !{} // false
     !!{} // true
     
    -

    Prototype

    +

    Prototype

    All objects have a prototype property. Whenever the interpreter looks for a property, it also checks in the object's prototype if the property is not found on the object itself. jQuery uses the prototype extensively to add methods to jQuery instances. Internally, jQuery makes jQuery.fn an alias of jQuery.prototype so you can use either one (though plugin developers have standardized on fn).

    var form = $("#myform");
     console.log( form.clearForm ); // undefined
     
    -// jQuery.fn == jQuery.prototype
    +// jQuery.fn === jQuery.prototype
     jQuery.fn.clearForm = function() {
       return this.find( ":input" ).each(function() {
         this.value = "";
    @@ -332,7 +332,7 @@ 

    Prototype

    form.clearForm();
    -

    Array

    +

    Array

    Arrays in JavaScript are mutable lists with a few built-in methods. You can define arrays using the array literal:

    var x = [];
    @@ -348,7 +348,7 @@ 

    Array

    x[ 0 ] = 1;
     y[ 2 ] // 3
     
    -

    Iteration

    +

    Iteration

    An array has a length property that is useful for iteration:

    for ( var i = 0; i < a.length; i++ ) {
    @@ -398,20 +398,23 @@ 

    Iteration

    Note: .unshift() method does not return a length property in Internet Explorer.

    -

    Boolean Default

    +

    Boolean Default

    An array, no matter if it has elements or not, never defaults to false:

    ![] // false
     !![] // true
     
    -

    Array<Type> Notation

    +

    Array<Type> Notation

    In the jQuery API you'll often find the notation of Array<Type>:

    dragPrevention    Array<String>
     

    This indicates that the method doesn't only expect an array as the argument, but also specifies the expected type. The notation is borrowed from Java 5's generics notation (or C++ templates).

    -

    PlainObject

    +

    Array-Like Object

    +

    Either a true JavaScript Array or a JavaScript Object that contains a nonnegative integer length property and index properties from 0 up to length - 1. This latter case includes array-like objects commonly encountered in web-based code such as the arguments object and the NodeList object returned by many DOM methods.

    +

    When a jQuery API accepts either plain Objects or Array-Like objects, a plain Object with a numeric length property will trigger the Array-Like behavior.

    +

    PlainObject

    The PlainObject type is a JavaScript object containing zero or more key-value pairs. The plain object is, in other words, an Object object. It is designated "plain" in jQuery documentation to distinguish it from other kinds of JavaScript objects: for example, null, user-defined arrays, and host objects such as document, all of which have a typeof value of "object." The jQuery.isPlainObject() method identifies whether the passed argument is a plain object or not, as demonstrated below:

    
    @@ -428,7 +431,10 @@ 

    PlainObject

    jQuery.isPlainObject( o ); // true
    -

    Date

    +

    Null

    +

    The null keyword is a JavaScript literal that is commonly used to express the absence of an intentional value.

    + +

    Date

    The Date type is a JavaScript object that represents a single moment in time. Date objects are instantiated using their constructor function, which by default creates an object that represents the current date and time.

    
    @@ -440,7 +446,7 @@ 

    Date

    new Date( 2014, 0, 1, 8, 15 );
    -

    Function

    +

    Function

    A function in JavaScript can be either named or anonymous. Any function can be assigned to a variable or passed to a method, but passing member functions this way can cause them to be called in the context of another object (i.e. with a different "this" object).

    function named() {}
    @@ -449,7 +455,7 @@ 

    Function

    You see a lot of anonymous functions in jQuery code:

    $( document ).ready(function() {});
    -$( "a" ).click(function() {});
    +$( "a)" ).on( "click", function() {});
     $.ajax({
       url: "someurl.php",
       success: function() {}
    @@ -457,7 +463,7 @@ 

    Function

    The type of a function is "function".

    -

    Arguments

    +

    Arguments

    Inside a function a special variable "arguments" is always available. It's similar to an array in that it has a length property, but it lacks the built-in methods of an array. The elements of the pseudo-array are the argument of the function call.

    function log( x ) {
    @@ -470,9 +476,9 @@ 

    Arguments

    The arguments object also has a callee property, which refers to the function you're inside of. For instance:

    var awesome = function() { return arguments.callee; }
    -awesome() == awesome // true
    +awesome() === awesome // true
     
    -

    Context, Call and Apply

    +

    Context, Call and Apply

    In JavaScript, the variable "this" always refers to the current context. By default, "this" refers to the window object. Within a function this context can change, depending on how the function is called.

    All event handlers in jQuery are called with the handling element as the context. @@ -480,7 +486,7 @@

    Context, Call and Apply

    $( document ).ready(function() {
       // this refers to window.document
     });
    -$( "a" ).click(function() {
    +$( "a)" ).on( "click", function() {
       // this refers to an anchor DOM element
     });
     
    @@ -493,7 +499,7 @@

    Context, Call and Apply

    scope.call( "foobar", [ 1, 2 ] ); // "foobar", 1 scope.apply( "foobar", [ 1, 2 ] ); // "foobar", 2
    -

    Scope

    +

    Scope

    In JavaScript, all variables defined inside a function are only visible inside that function scope. Consider the following example:

    // global
    @@ -507,7 +513,7 @@ 

    Scope

    It defines a variable x in the global scope, then defines an anonymous function and executes it immediately (the additional parentheses are required for immediate execution). Inside the function another variable x is defined with a different value. It is only visible within that function and doesn't overwrite the global variable.

    -

    Closures

    +

    Closures

    Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope. In the following example, the variable counter is visible within the create, increment, and print functions, but not outside of them.

    function create() {
    @@ -527,7 +533,7 @@ 

    Closures

    The pattern allows you to create objects with methods that operate on data that isn't visible to the outside—the very basis of object-oriented programming.

    -

    Proxy Pattern

    +

    Proxy Pattern

    Combining the above knowledge gives you as a JavaScript developer quite a lot of power. One way to combine that is to implement a proxy pattern in JavaScript, enabling the basics of aspect-oriented programming (AOP):

    (function() {
    @@ -541,10 +547,10 @@ 

    Proxy Pattern

    The above wraps its code in a function to hide the "proxied"-variable. It saves jQuery's setArray-method in a closure and overwrites it. The proxy then logs all calls to the method and delegates the call to the original. Using apply(this, arguments) guarantees that the caller won't be able to notice the difference between the original and the proxied method.

    -

    Callback

    +

    Callback

    A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered. jQuery's event system uses such callbacks everywhere:

    -
    $( "body" ).click(function( event ) {
    +
    $( "body" ).on( "click", function( event ) {
       console.log( "clicked: " + event.target );
     });
     
    @@ -552,15 +558,23 @@

    Callback

    Some callbacks are required to return something, others make that return value optional. To prevent a form submission, a submit event handler can return false:

    -
    $( "#myform" ).submit(function() {
    +
    $( "#myform" ).on( "submit", function() {
       return false;
    -});
    +} );
     

    Instead of always returning false, the callback could check fields of the form for validity, and return false only when the form is invalid.

    -


    +

    Error

    +

    An instance of an Error object is thrown as an exception when a runtime error occurs. Error can also be used as base to define user custom exception classes. In JavaScript an error can be thrown as shown below: +

    +
    throw new Error( "The argument provided is incorrect" );
    +
    +

    An error can also be thrown by the engine under some circumstances. For example, when trying to access a property of null:

    -

    Selector

    +
    var obj = null;
    +console.log( obj.foo() );
    +
    +

    Selector

    A selector is used in jQuery to select DOM elements from a DOM document. That document is, in most cases, the DOM document present in all browsers, but can also be an XML document received via Ajax.

    The selectors are a composition of CSS and custom additions. All selectors available in jQuery are documented on the Selectors API page. @@ -582,7 +596,7 @@

    Event

    The standard events in the Document Object Model are: blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, and keyup. Since the DOM event names have predefined meanings for some elements, using them for other purposes is not recommended. jQuery's event model can trigger an event by any name on an element, and it is propagated up the DOM tree to which that element belongs, if any.

    -

    Element

    +

    Element

    An element in the Document Object Model (DOM) can have attributes, text, and children. It provides methods to traverse the parent and children and to get access to its attributes. Due to inconsistencies in DOM API specifications and implementations, however, those methods can be a challenge to use. jQuery provides a "wrapper" around those elements to help interacting with the DOM. But sometimes you will be working directly with DOM elements, or see methods that (also) accept DOM elements as arguments.

    Whenever you call jQuery's .each() method or one of its event methods on a jQuery collection, the context of the callback function — this — is set to a DOM element. @@ -597,7 +611,17 @@

    Element

    You could replace this.value with $(this).val() to access the value of the text input via jQuery, but in that case you wouldn't gain anything.

    -

    jQuery

    +

    Text

    +

    Text is a node of the Document Object Model (DOM) that represents the textual content of an element or an attribute. Consider the following code: +

    +
    <p id="target"><b>Hello</b> world</p>
    +

    If you retrieve the children of the paragraph of the example as follows: +

    +
    var children = document.getElementById( "target" ).childNodes;
    +
    +

    you obtain two children. The first one is the element representing the b tag. The second child is a text node containing the string " world". +

    +

    jQuery

    A jQuery object contains a collection of Document Object Model (DOM) elements that have been created from an HTML string or selected from a document. Since jQuery methods often use CSS selectors to match elements from a document, the set of elements in a jQuery object is often called a set of "matched elements" or "selected elements".

    The jQuery object itself behaves much like an array; it has a length property and the elements in the object can be accessed by their numeric indices [0] to [length-1]. Note that a jQuery object is not actually a Javascript Array object, so it does not have all the methods of a true Array object such as join(). @@ -614,31 +638,30 @@

    jQuery

    $( ".badEntry" ).css({ color: "red" });
     
    -

    XMLHttpRequest

    +

    XMLHttpRequest

    Some of jQuery's Ajax functions return the native XMLHttpRequest (XHR) object, or pass it as an argument to success/error/complete handlers, so that you can do additional processing or monitoring on the request. Note that Ajax functions only return or pass an XHR object when an XHR object is actually used in the request. For example, JSONP requests and cross-domain GET requests use a script element rather than an XHR object.

    -

    Although the XHR object is a standard, there are variations in its behavior on different browsers. Refer to the W3C site and browsers' documentation for more information: +

    Although the XHR object is a standard, there are variations in its behavior on different browsers. Refer to the WHATWG site and Mozilla Developer Network for more information:

    -
    • W3C standard -
    • Apple (Safari) -
    • Mozilla (Firefox) -
    • Microsoft (Internet Explorer) -
    • Opera + -

      Google does not appear to have an official page for their XHR documentation for Chrome. As of version 5, Chrome does not support the use of the file protocol for XHR requests. -

      -

      jqXHR

      +

      jqXHR

      As of jQuery 1.5, the $.ajax() method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the jqXHR section of the $.ajax entry

      +

      Thenable

      +

      Any object that has a then method.

      Deferred Object

      As of jQuery 1.5, the Deferred object provides a way to register multiple callbacks into self-managed callback queues, invoke callback queues as appropriate, and relay the success or failure state of any synchronous or asynchronous function.

      Promise Object

      -

      This object provides a subset of the methods of the Deferred object (then, done, fail, always, pipe, progress, and state) to prevent users from changing the state of the Deferred. +

      This object provides a subset of the methods of the Deferred object (then, done, fail, always, pipe, progress, state and promise) to prevent users from changing the state of the Deferred.

      Callbacks Object

      A multi-purpose object that provides a powerful way to manage callback lists. It supports adding, removing, firing, and disabling callbacks. The Callbacks object is created and returned by the $.Callbacks function and subsequently returned by most of that function's methods.

      +

      Document

      +

      A document object created by the browser's DOM parser, usually from a string representing HTML or XML.

      XML Document

      A document object created by the browser's XML DOM parser, usually from a string representing XML. XML documents have different semantics than HTML documents, but most of the traversing and manipulation methods provided by jQuery will work with them.

      Assert

      -

      A reference to or instance of the object holding all of QUnit's assertions. See the API documentation for QUnit.assert for details.

      +

      A reference to or instance of the object holding all of QUnit's assertions. See the API documentation for QUnit.assert for details.

      diff --git a/redirects.json b/redirects.json new file mode 100644 index 00000000..ba33f9dd --- /dev/null +++ b/redirects.json @@ -0,0 +1,4 @@ +{ + "/api/": "/resources/api.xml", + "/extending-ajax/": "/jQuery.ajax/#extending-ajax" +} diff --git a/resources/events.js b/resources/events.js index e00efb36..9b01b7e6 100644 --- a/resources/events.js +++ b/resources/events.js @@ -1,31 +1,31 @@ jQuery.print = function(message, insertionType) { - if (typeof(message) == 'object') { - var string = '{
      ', - values = [], - counter = 0; - $.each(message, function(key, value) { - if (value && value.nodeName) { - var domnode = '<' + value.nodeName.toLowerCase(); - domnode += value.className ? ' class="' + value.className + '"' : ''; - domnode += value.id ? ' id="' + value.id + '"' : ''; - domnode += '>'; - value = domnode; - } - values[counter++] = key + ': ' + value; - }); - string += values.join(',
      '); - string += '
      }'; - message = string; - } + if (typeof(message) == 'object') { + var string = '{
      ', + values = [], + counter = 0; + $.each(message, function(key, value) { + if (value && value.nodeName) { + var domnode = '<' + value.nodeName.toLowerCase(); + domnode += value.className ? ' class="' + value.className + '"' : ''; + domnode += value.id ? ' id="' + value.id + '"' : ''; + domnode += '>'; + value = domnode; + } + values[counter++] = key + ': ' + value; + }); + string += values.join(',
      '); + string += '
      }'; + message = string; + } - var $output = $('#print-output'); + var $output = $('#print-output'); - if ($output.length === 0) { - $output = $('