jquery deprecation functions and new functions

Introduction:

-Fast, small, javascript library.
-traversal, manipulation
-Event handling, animation, ajax, easy to use API
– multitude of browsers
– versatility and extensibility.
– millions of people to write javascript.

Deprecated Functions from new Release

Overview:
jQuery 1.9 removes or modifies several APIs that behaved inconsistently or inefficiently in the past. The majority of these changes have been foreshadowed by their deprecation in previous versions of jQuery, particularly 1.7 and 1.8.

jQuery Migrate Plugin

This plugin can be used to detect and restore APIs or features that have been deprecated in jQuery and removed as of version 1.9.

https://github.com/jquery/jquery-migrate

Ideally this would only be used as a short-term solution.

Old functions

1. jQuery.browser() removed
The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr.

2. . live() removed
The .live() method has been deprecated since jQuery 1.7 and has been removed in 1.9. We recommend upgrading code to use the .on() method instead. To exactly match

for example, you can write

3. .die() removed
The .die() method has been deprecated since jQuery 1.7 and has been removed in 1.9. We recommend upgrading code to use the .off() method instead. To exactly match

for example, you can write

4. jQuery.sub() removed
The jQuery.sub() method has been moved to the jQuery Migrate plugin. The number of use cases where it proved valuable were not enough to justify keeping it in core. The jQuery Migrate plugin adds back this functionality.

5. .add()
The .add() method is always supposed to return its results in document order. Prior to 1.9, .add() would not sort nodes in document order if either the context or the input set started with a disconnected node (not in a document). Now, nodes are always returned in document order and disconnected nodes are placed at the end of the set.

Reference :
– http://jquery.com/upgrade-guide/1.9/

New Functions

.css()
Get the value of a style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.

.finish()
Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
Eg: $( “div.box” ).finish();

:first-of-type Selector
Selects all elements that are the first among siblings of the same element name.
Eg: $( “span:first-of-type” ).addClass( “fot” );

:lang() Selector
Selects all elements of the specified language.

Eg:

:last-of-type Selector
Selects all elements that are the last among siblings of the same element name.
Eg: $( “span:last-of-type” ).css({ color:”red”, fontSize:”80%” });

:nth-last-child() Selector
Selects all elements that are the nth-child of their parent, counting from the last element to the first.
Eg: $( “ul li:nth-last-child(2)” ).append( “ Hello” );

:nth-last-of-type() Selector
Selects all elements that are the nth-child of their parent, counting from the last element to the first.

:nth-of-type() Selector
Selects all elements that are the nth child of their parent in relation to siblings with the same element name.
Eg: $( “span:nth-of-type(2)” ).append( “ is 2nd sibling span” );
Output: John, Kim, Adam is 2nd sibling span, Rafael, Oleg

:only-of-type Selector
Selects all elements that have no siblings with the same element name.
Eg: $( “button:only-of-type” ).text( “Alone” ).css( “border”, “2px blue solid” );

:root Selector
Selects the element that is the root of the document.
Eg:

Output:
The root of this document is: HTML

:target Selector
Selects the target element indicated by the fragment identifier of the document’s URI.