With the release of jQuery 1.4.3, there are a number of new features and updates to the library that are worth checking out. They can help in contributing to future projects and making sure that your existing work is compatible.
Here’s a run down of what you can expect…
Ajax Awareness
jQuery now offers a property that returns true if the current browser supports Ajax functionality, and false if not.
[cc lang=”javascript”]
if($.support.ajax === true) {
// nice, we support ajax!
} else {
// bummer. mobile or very outdated browser..
}
[/cc]
Great for you’re developing an application that’s going to be used in a wide array of browsers and platforms.
Prevent Events
When setting up custom event handlers, we often have to prevent the default event from firing in addition to our own code. jQuery 1.4.3’s new event module makes it easy:
[cc lang=”javascript”]
$(“#codeAnchor”).bind(“click”, false);
[/cc]
Much cleaner than previous alternatives.
Type It Out
One of the challenges of working with JavaScript is the nature of a dynamic language. Depending on the size of your application, there’s a significant chance that you may expect a variable to be of one type rather than another.
And since everything is an object in JavaScript, the built-in ‘type of’ operator can be more harmful than not. Luckily, jQuery 1.4.3 offers an alternative:
[cc lang=”javascript”]
$.type(false) === “boolean”
$.type(new Date()) === “date”
$.type(42) === “number”
$.type(“8BIT”) === “string”
$.type(function(){}) === “function”
$.type([]) === “array”
[/cc]
Nice.
There are a number of new features that you can check out on the official jQuery blog. Don’t forget to grab a copy of the library, either!
Speak your mind...