"Sharp jquery" study notes 01

Source: Internet
Author: User

Chapter One understanding jqueryfirst, the Common JS library
    1. Prototype one of the earliest JS libraries. The use of JS method combination, the shortcomings of the structure of loose.
    2. Dojo offline storage API, generate icon component, Vector graphics library, comet support. Enterprise-Class JS library, the shortcomings of the document is not complete, the API is not stable.
    3. YUI Yahoo developed the rich interactive Web program toolset.
    4. Exit JS focus on the interface
    5. MooTools Lightweight JS framework for modular Thinking
    6. JQuery lightweight, powerful selectors, and more.
ii. Advantages of jquery
    1. Lightweight 30K or so
    2. Powerful Selector
    3. Excellent DOM encapsulation
    4. Reliable event-handling mechanism
    5. Ajax Perfect
    6. Non-polluting top-level variables
    7. Browser compatible
    8. Chained calls
    9. Implicit iteration
    10. Behavioral structure Separation
    11. Rich Plugins
    12. Document Perfection
    13. Open source
third, the preparation of matters of note

Chaining calls should be noted:

    • No more than 3 operations for the same object, write directly as one line
    • More operations on the same object, one action per line
    • A small number of operations for multiple objects, one line per object (Indent child elements)
Iv. jquery objects and Dom objects

Dom objects are objects that are obtained directly from the DOM tree, and can be used with the JS method and not by the jquery method . jquery objects are the DOM objects that are wrapped in jquery, and you can use the JQuery method , and you cannot use the JS method (the variables obtained by the JQuery object are preceded by $ to differentiate).

The two convert each other:

    • The jquery object is converted to a DOM object:
    1. [index] var dom=$ ("div") [0];
    2. Get (Index) var dom=$ ("div"). Get (0);
    • The DOM object is converted to a jquery object: You can use $ () to package the DOM object directly.
v. jquery and other JS Libraries conflict resolution ($ transfer problem)

For jquery, global variables are stored in their own namespaces and generally do not conflict with other libraries

    • jquery libraries are introduced after other libraries
    1. Jquery.noconflict (); Give variable $ control to other libraries

JQuery (function () {//using Jqery

Writing jquery programs;

})

2. Var $j =jquery.noconflict (); Customizing a shortcut

$j (function () {//Use Jqery, use a custom shortcut--$j

Writing jquery programs;

})

If you do not want to customize you also want to use $ (), regardless of the other library $ () method, and do not want to conflict with other libraries. Use:

    1. Jquery.noconflict (); Give variable $ control to other libraries

      JQuery (function ($) {//Use Jqery to set the letter executed when the page is loaded, continue using $ () inside the function

      Writing jquery programs;

      })

    2. Jquery.noconflict (); Give variable $ control to other libraries

(function ($) {///define an anonymous function and set the parameter to $, the inside of the anonymous function is Jqery, continue using $ () inside the function

$ (function () {

Writing jquery programs;

})

}) (JQuery);

    • jquery Library introduced in front of other libraries

Without calling Jquery.noconflict (), using jquery directly for jquery, the other libraries use $ ().

"Sharp jquery" study notes 01

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.