jQuery major update
jQuery 1.2
New Features
- Selectors
- :has(selector)
- :header
- :animated
- XPath Selector Plugin
- Attributes
- .val() Overhaul
- Traversing
- .map()
- .prevAll() / .nextAll()
- .slice()
- .hasClass()
- .andSelf()
- .contents()
- Manipulation
- .wrapInner() / .wrapAll()
- .replaceWith() / .replaceAll()
- .clone(true) Event Cloning
- CSS
- .offset()
- .height() / .width() for document and window
- Ajax
- Partial .load()
- Cross-Domain getScript
- JSONP
- .serialize() Overhaul
- Disable Caching
- Effects
- .stop()
- %/em Animations
- Color Animations
- Relative Animations
- Queue Control
- :animated
- step: Function
- Events
- Namespaced Events
- .triggerHandler()
- Internals
- Documentation Move
- Expando Management
Removed Functionality
We’ve removed a number of methods in jQuery 1.2 that were relatively unused, causing confusion, or were inefficient. Wherever possible, we’ve provided alternate methods for performing the actions.
With jQuery 1.2, as with the jQuery 1.1 release, a backwards compatibility plugin has been provided. Thus, if you wish to continue using these particular methods, you’ll be able to use that plugin and continue doing so.
Additionally, in order to handle the XPath changes another, separate, plugin has been made available that will handle XPath selector functionality in jQuery.
Selectors
$("div//p") XPath Descendant Selector
Please use the CSS $("div p") selector instead. Or, use the XPath Compatibility Plugin.
$("div/p") XPath Child Selector
Please use the CSS $("div > p") selector instead. Or, use the XPath Compatibility Plugin.
$("p/../div") XPath Parent Selector
Please use the $("p").parent("div") selector instead. Or, use the XPath Compatibility Plugin.
$("div[p]") XPath Contains Predicate Selector
Please use the new $("div:has(p)") selector instead. Or, use the XPath Compatibility Plugin.
$("a[@href]") XPath Attribute Selector
Note: While this selector is deprecated, it has not yet been removed as of this release (jQuery 1.2).
It is now recommended that you use the CSS selector $("a[href]") instead. Or, use the XPath Compatibility Plugin.
DOM Manipulation
$("div").clone(false)
Calling the clone method with an argument is being deprecated (the clone method, as a whole, is being kept). Instead of calling .clone(false) you should now do: .clone().empty() instead.
DOM Traversing
$("div").eq(0)
This method is being deprecated for the use of the new .slice() method (which works identically to an array’s slice method). You can duplicate .eq() like so:
$("div").slice(0,1);
Additionally, .eq(0) can be duplicated in the following ways:
$("div:eq(0)")
$("div:first")
$("div").lt(2)
This method is being deprecated for the use of the new .slice() method (which works identically to an array’s slice method). You can duplicate .lt() like so:
$("div").slice(0,2);
Additionally, .lt(2) can be duplicated in the following way:
$("div:lt(2)")
$("div").gt(2)
This method is being deprecated for the use of the new .slice() method (which works identically to an array’s slice method). You can duplicate .gt() like so:
$("div").slice(3);
Additionally, .gt(2) can be duplicated in the following way:
$("div:gt(2)")
$("div").contains('text')
This method is being deprecated in favor of just using a regular .filter() statement. You can duplicate .contains() like so:
$("div").filter(":contains(Your Text)");
Ajax
$("#elem").loadIfModified("some.php")
This convenience method is being removed in favor of the long form use of $.ajax():
$.ajax({
url: "some.php",
ifModified: true,
success: function(html){
$("#elem").html(html);
}
});
$.getIfModified("some.php")
This convenience method is being removed in favor of the long form use of $.ajax():
$.ajax({
url: "some.php",
ifModified: true
});
$.ajaxTimeout(3000)
This convenience method is being removed in favor of the long form use of the more-explicit $.ajaxSetup():
$.ajaxSetup({timeout: 3000});
$(...).evalScripts()
This method is no longer necessary in jQuery – all scripts included in HTML strings are automatically evaluated when injected into the document. No substitute method is needed.
If any plugins that you’re using still require some of the old functionality, you can feel free to include the jQuery 1.1 Compatibility Plugin or the XPath Compatibility Plugin, depending on the situation.