1 Understanding jquery

Source: Internet
Author: User

A code style and variant style

1-chain Operation style:

(1) No more than three operations on the same object can be written on one line

(2) For more operations on the same object, it is recommended to write one action per line

(3) For a small number of operations on multiple objects, you can write one line per object, involving child elements, you can test the rate appropriate indentation.

2 Notes//

Two jquery objects and Dom objects

Dom:dom Tree

jquery object: The object after wrapping the DOM object through jquery.

Dom methods cannot be used in jquery objects, nor can DOM objects use the jquery method.

jquery converted to Dom:[get] or get (index)

The jquery object is an array-like object: Var $cr =$ ("#id"), var cr= $cr [0], or var cr= $cr. Get (0)

Dom converted to jquery:$ (DOM object)

Three jquery and other JS library conflict issues

1 jquery Imports after the introduction of other libraries: (1) call Jquery.onconflict () directly, and then use jquery (2) to customize the alternate name such as: Var $j =jquery.noconflict; (3) Jquery.onconflict ( ), jquery (function ($) {});(4) jquery.onconflict ();(function ($) {}) (jquery);

(3) (4) Advantages of the method: Full compatibility can be achieved with minimal code.

2 jquery Import before introducing another library: use jquery directly (function () {}); no need to call Jquery.onconflict ()

1 Understanding jquery

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.