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