Wednesday, July 6, 2011

Jquery

Jquery prototype is the second after another excellent Javascr Pt framework. It is a lightweight JS Library ( compression after only 21k ), it is compatible with CSS3, is compatible with all browsers ( IE 6 +, FF 1.5 +, Safari 2 +, Opera 9 +). JQuery allows users to more easily deal with HTML documents, events, to achieve animation effects, and convenient for the site to provide AJAX interaction. JQuery also has a big advantage is that its documentation is complete, and all kinds of application also said very detailed, and many mature plugins available for selection. JQuery enables the user to maintain the HTML code and HTML content separation, that is to say, no longer in HTML inserted inside a JS to invoke a command, only need to define the ID.
Brief introduction
JQuery John Resig created by the Americans, has attracted from all over the world numerous JavaScript master to join its team, including those from Germany 's Jö RN Zaefferer, Romania Stefan Petre and so on. JQuery prototype is the second after another excellent Javascr Pt framework. Its purpose is - WRITE LESS, DO MORE, write less, do more.
Find you!
In the preparation of JS library code, you must often and " $" dollar sign to deal with it? Both prototype and DWR use $ frequent document.getElementById ( ) operation. JQuery did, however, its function is far from the case, see the following code in jQuery, you'll find it beautiful
Code
Var someElement = $ (" # myId." ) ;
Look than the other two frame to a #, well, have a look the following directions:
Code
$ ("div P" ) ; / / (1 )
$ ("div.container" ) ; / / (2 )
$ ("div # MSG" ) ; / / (3 )
$ ("table a", context) ; / / (4 )
In prototype seen in this manner? The first line of code to get all div under the label of P elements. Second lines of code to get class container div elements, third lines of code are labels below ID MSG div elements ( but not the best way to write, because jQuery needs to traverse all of the div elements, with ID element directly with $ (" # ID." ) ). Fourth lines of code to get context context table inside all the link element.
If you are familiar with CSS, you will find the style of writing is very familiar! Yes. It is. See the secret. JQuery is so powerful that you can easily find any of the elements in DOM, this is jQuery at the beginning of the design of query real meaning (query).
The Jquery object
JQuery provides a lot of traversal function, such as each ( FN), but these functions use the premise is that you use the object is a Jquery object. Make a Dom object into a Jquery object is very simple, through the following ways : ( only a part )
Code
Var a = $ (" # CID." ) ;
Var B = $ ( "< p > Hello < / P > ") ;
Var C = document.createElement ("table" ) ;
Var TB = $ ( c) ;

No comments:

Post a Comment