JQuery-how native to each other

Source: Internet
Author: User

Today, when we study the source code, we find that it is not necessary to use get () to convert natively, using native methods.

Native-jquery Object

var obj=document.xxx

$ (obj). css ();

You can also direct $ (document.xxx)

jquery objects-Native

Method one: Get ()

    $ (' Li '). get ();

Is that it? The set of elements acquired by JQ is converted to a native object, and a get () parameter can also be used to represent the one that is currently being converted, which can be a native method.

Many ask the difference between EQ () and get ():

It's easy, you use EQ () and then you can't use the native method, followed by the JQ method.

           $ (' input '). EQ (1). css (' background ', ' blue ')

      Instead, using get (), you can only use the native method

           $ (' input '). Get (1). Style.background (' Blue ')

  Method Two: Direct use subscript, that is to say there are some cases you can save get (), two directly can use the native method to accomplish what you want to do, it is not more convenient

Test 1: Looping

      

    Test 2: Form

      

    Test 3: After the subscript is added, the method of using JQ will error

      

JQuery-how native to each other

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.