Official jQuery website

Source: Internet
Author: User

Official jQuery website

When studying the source code today, we found that native conversion can be performed without using get () and native methods.

Native-jQuery object

Var obj = document. xxx

((Obj).css ();

You can also directly $ (document. xxx)

JQuery object-native

Method 1: get ()

    $ ('Lil'). get ();

This is because the set of elements obtained by jq is converted to a native object. In get (), parameters can also be placed to indicate that the currently converted element can use the native method.

Many questions about the difference between eq () and get:

It is very simple. If you use eq (), you cannot use the native method later. It is followed by the jq method.

           Certificate ('input'0000.eq(1).css ('background', 'blue ')

      Instead, if get () is used, you can only use the native method.

           $ ('Input'). get (1). style. background ('blue ')

 

Method 2: Use the subscript directly, that is, in some cases, you can save get (). Second, you can directly use the native method to accomplish what you want to do. Isn't it more convenient?

Test 1: loop

      

    Test 2: Form

      

    Test 3: After the subscript is added, an error is reported when jq is used.

      

 

 

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.