$ (this) what exactly is a

Source: Internet
Author: User

The students who often use jquery are certainly not unfamiliar with the $ (this), because they are often used.

This thing is really good, for example, there are a lot of elements when we select which element, we give him some action,

We can use the $ (this) as well as the need to get the index value of the current element in the parent container.

Well, it's really a good thing, but if you ask me, the principle of this thing, I really do not know, so I checked the information, decided to thoroughly understand him.

$ (this) is divided into two parts, $ () and this one to analyze:

$ () Needless to say it is jquery is a method that returns what that is? We can print it in the console.

An object is a jquery object that is returned, which means that we use $ () to invoke the methods and properties of jquery.

And then, in terms of what this,this is, let's print it.

He is an HTML object that represents the object in which the context is located, that is, he is relative, and the things that are used in different places are not the same. Well, if we put it in $ (), try it.

Not surprisingly, this must also refer to the currently selected jquery object.

What is the difference between this and $ (this)?

This indicates that the current context object is an HTML object that can call the properties of an HTML object, method.

$ (this), which represents the context object is a jquery object that can invoke the methods and property values of jquery.

Please correct me if there are errors or omissions.

$ (this) what exactly is a

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.