Notes on "sharp jQuery"-One Sections, sharp jquery
Chapter 1
1. $ is a short form of jQuery
2. You cannot use any DOM object methods in jQuery: $ ("# id"). innerHTML, $ ("# id"). checked,
You can use: $ ("#id”).html (), $ ("# id"). attr ("checked ");
3. DOM objects cannot use any method in jQuery:
Document.getelementbyid(registry.id=}.html ();
4. Convert jQuery into a DOM object:
1) var $ c = $ ("# cr ");
Var c = $ c [0] Or var c = $ c. get (0)
5. Convert the DOM into a jQuery object:
Var cr = document. getElementById ("# id ");
Var $ cr = $ (cr)
6. When jQuery conflicts with other libraries:
1) jQuery is imported after other libraries
(1) Call jQuery. noConflict (); // hand over control of variable $ to other libraries
(2) If you want to define a shortcut:
Var $ j = jQuery. noConflict ();
$ J ("# id ")
2) jQuery is imported before other libraries
Use "jQuery" directly, and use the $ () method for other libraries.
Chapter 2
1. $ (". one + div") is equivalent to $ (". one"). next ("div ");
2. $ (". one ~ Div) is equivalent to $ (". one"). nextAll ("div ");
3. PS:
1) the selector cannot contain "·", "#", "(", "]". If used, add "\" to the front.
2) When using Version 1.3.1 or later, you do not need to add @ to the front of the attribute, for example, $ ("div [title = 'test']").
3) considerations when the selector contains spaces:
$ ('. Test: Den den') [descendant selector] is different from $ ('. test: Den den') [filter selector]