diff --git a/entries/addClass.xml b/entries/addClass.xml
index 476251d8..8b8a0564 100644
--- a/entries/addClass.xml
+++ b/entries/addClass.xml
@@ -19,6 +19,8 @@
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 3.0, the As of jQuery 3.0 this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the More than one class may be added at a time, separated by a space, to the set of matched elements, like so: 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. In jQuery 1.4.3 setting an element's data object with Prior to jQuery 1.4.3 (starting in jQuery 1.4) the jQuery 3 changes the behavior of this method to align it to the Dataset API specifications. Specifically, jQuery 3 transforms every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter by the uppercase version of the letter as per definition of [the algorithm of the Dataset API](http://www.w3.org/TR/html5/dom.html#dom-dataset). Writing a statement like Due to the way browsers interact with plugins and external code, 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).class
attribute is used instead. So, .addClass()
can be used on XML or SVG documents.
$( "p" ).addClass( "myClass yourClass" );
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 @@
.data(obj)
extends the data previously stored with that element..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.$( "body" ).data( { "my-name": "aValue" } ).data();
will return { myName: "aValue" }
..data()
method cannot be used on <object>
(unless it's a Flash plugin), <applet>
or <embed>
elements.
jQuery 3 changes the behavior of this method to align it to the Dataset API specifications. Specifically, jQuery 3 transforms every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter by the uppercase version of the letter as per definition of [the algorithm of the Dataset API](http://www.w3.org/TR/html5/dom.html#dom-dataset). Writing a statement like $( "body" ).data( { "my-name": "aValue" } ).data();
will return { myName: "aValue" }
.
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.
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.
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.
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()
.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()
.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.
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,
diff --git a/entries/jQuery.get.xml b/entries/jQuery.get.xml
index 51b50c64..6e17c416 100644
--- a/entries/jQuery.get.xml
+++ b/entries/jQuery.get.xml
@@ -75,7 +75,7 @@ jqxhr.always(function() {
});
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.
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.
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
.
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.
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.
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
.
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/.
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.
As of jQuery 3.0, $.parseJSON
is deprecated. To parse JSON objects, use the native JSON.parse
method instead.
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.
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.
The $.uniqueSort()
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.
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.
+
+ Promise.all
-like fulfillment aggregation.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:
If no arguments are provided, jQuery.when()
will return a resolved Promise.
+$.when().then(function( x ) {
+ alert( "I fired immediately" );
+});
+
+ If a single argument is provided and it is a Promise or has a then
method, jQuery.when()
will return a Promise that will resolve or reject identically to the argument.
$.when( $.ajax( "test.aspx" ) ).then(function( data, textStatus, jqXHR ) {
alert( jqXHR.status ); // Alerts 200
});
- If a single argument is passed to jQuery.when()
and it is not a Deferred or a Promise, it will be treated as a resolved Deferred and any doneCallbacks attached will be executed immediately. The doneCallbacks are passed the original argument. In this case any failCallbacks you might set are never called since the Deferred is never rejected. For example:
If any other single argument is provided, jQuery.when()
will return a Promise that is resolved to it.
$.when( { testing: 123 } ).done(function( x ) {
alert( x.testing ); // Alerts "123"
});
- If you don't pass it any arguments at all, jQuery.when()
will return a resolved promise.
-$.when().then(function( x ) {
- alert( "I fired immediately" );
-});
-
- In the case where multiple Deferred objects are passed to jQuery.when()
, the method returns the Promise from a new "master" Deferred object that tracks the aggregate state of all the Deferreds it has been passed. The method will resolve its master Deferred as soon as all the Deferreds resolve, or reject the master Deferred as soon as one of the Deferreds is rejected. If the master Deferred is resolved, the doneCallbacks for the master Deferred are executed. The arguments passed to the doneCallbacks provide the resolved values for each of the Deferreds, and matches the order the Deferreds were passed to jQuery.when()
. For example:
If more than one argument is provided, jQuery.when()
will return the Promise from a new "master" Deferred object that tracks their aggregate state (upgrading each to a Deferred object as in the single-argument case where necessary). The master Deferred will resolve as soon as all subordinates resolve, or reject as soon as one is rejected. If the master Deferred is resolved, the resolution context and values of each subordinate are preserved in its resolution context (an array of all the resolution contexts) and resolution values (the resolution values of each subordinate appear as a single value, with multi-valued resolutions theirselves becoming arrays), each preserving the order in which the subordinate was provided to jQuery.when()
. For example:
var d1 = $.Deferred();
var d2 = $.Deferred();
+var d3 = $.Deferred();
-$.when( d1, d2 ).done(function ( v1, v2 ) {
- console.log( v1 ); // "Fish"
- console.log( v2 ); // "Pizza"
+$.when( d1, d2 ).done(function ( v1, v2, v3 ) {
+ console.log( v1 ); // "Fish"
+ console.log( v2 ); // ["Pizza", "Pie"]
+ console.log( v3 ); // undefined
+ console.log( this ); // [{ where: "Ocean" }, undefined, undefined]
});
-d1.resolve( "Fish" );
-d2.resolve( "Pizza" );
+d1.resolveWith( { where: "Ocean" }, [ "Fish" ] );
+d2.resolve( "Pizza", "Pie" );
+d3.resolve();
- In the event a Deferred was resolved with no value, the corresponding doneCallback argument will be undefined. If a Deferred resolved to a single value, the corresponding argument will hold that value. In the case where a Deferred resolved to multiple values, the corresponding argument will be an array of those values. For example:
+If more than one argument is provided and one of the arguments is rejected, jQuery.when()
immediately rejects with corresponding context and values. Note that some of the subordinates may still be unresolved at that point. For example:
var d1 = $.Deferred();
var d2 = $.Deferred();
var d3 = $.Deferred();
-$.when( d1, d2, d3 ).done(function ( v1, v2, v3 ) {
- console.log( v1 ); // v1 is undefined
- console.log( v2 ); // v2 is "abc"
- console.log( v3 ); // v3 is an array [ 1, 2, 3, 4, 5 ]
+$.when( d1, d2 ).fail(function ( rejection ) {
+ console.log( rejection ); // "Pie"
+ console.log( this ); // { type: "Pizza" }
});
-d1.resolve();
-d2.resolve( "abc" );
-d3.resolve( 1, 2, 3, 4, 5 );
+d1.resolve( "Fish" );
+d2.rejectWith( { type: "Pizza" }, [ "Pie" ] );
+d3.resolve();
- 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.
Regardless of provided arguments, methods of the returned 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.
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 );
diff --git a/entries/removeClass.xml b/entries/removeClass.xml
index 8bb11196..6a85ea72 100644
--- a/entries/removeClass.xml
+++ b/entries/removeClass.xml
@@ -19,6 +19,8 @@
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.
+ Before jQuery version 3.0, 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 3.0 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" )
diff --git a/entries/selector.xml b/entries/selector.xml
index 971a2535..e9e61c1e 100644
--- a/entries/selector.xml
+++ b/entries/selector.xml
@@ -1,5 +1,5 @@
-
+
.selector
1.3
diff --git a/entries/toggleClass.xml b/entries/toggleClass.xml
index 1d034d86..5a18aa05 100644
--- a/entries/toggleClass.xml
+++ b/entries/toggleClass.xml
@@ -1,67 +1,62 @@
-
- .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 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 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>
:
+
<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 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.
+
$( "div.foo" ).toggleClass(function() {
if ( $( this ).parent().is( ".bar" ) ) {
return "happy";
@@ -69,17 +64,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.
-
-
-
-
-
- Add the "highlight" class to the clicked paragraph on every third click of that paragraph, remove it every first and second click.
-
-
-
-
-
- Toggle the class name(s) indicated on the buttons for each div.
-
-
-
-
-
-
-
-
-
-
-
-
+
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.
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.
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.
this
refers to the current element in the set.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.