JQuery1.4 has just been released. this version is not a simple improvement. It not only contains many new features, but also improves many functions and makes great effort in performance optimization, this article will discuss these new features and enhancements, hoping to help you. first you can download the latest 1.4 version from here: http://code.jquery.com/jquery-1.4.js
1. Pass attributes to jQuery
In versions earlier than 1.4, jQuery used the "attr" method to add attributes to the element set. The "attr" method can not only pass attribute names and values, you can also pass an object set that contains multiple attributes. In 1.4, apart from creating new objects, it can now pass attribute objects as parameters to jQuery functions or objects themselves. For example, you can create a link element containing multiple attributes. The Code 1.4 is as follows:
JQuery ('',{
Id:'Gid',
Href:'Http://www.google.com',
Title:'Non-harmonious google Edition',
Rel:'External',
Text:'Go to Google!'
});
You may notice the "text" attribute and guess what it is, because tag a does not have the "text" attribute. When you pass certain attributes, jquery 1.4 will also check and use its own method. Therefore, the "text" attribute above allows jQuery to call its ". text ()" method and enter "Google! "As its unique parameter.
Here is a better example:
JQuery ('',{
Id:'Foo',
Css :{
FontWeight:700,
Color:'Green'
},
Click:Function(){
Alert ('Foo has been clicked!');
}
});
The "id" attribute is added as a common attribute. However, the "css" and "click" attributes correspond to specific jQuery methods. The above code is written as follows before 1.4:
JQuery ('')
. Attr ('Id','Foo')
. Css ({
FontWeight:700,
Color:'Green'
})
. Click (Function(){
Alert ('Foo has been clicked!');
});