Notes on "sharp jQuery"-One Sections, sharp jquery

Source: Internet
Author: User

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]

 

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.