A word to tell you what jquery $ (this) exactly refers to, how to use

Source: Internet
Author: User

Read the online a lot about the jquery $ (this) explanation, the feeling is very vague.

Let me say my own understanding.

This represents the current object, as shown in the example below.

[JavaScript]View PlainCopy 
  1. <! DOCTYPE html>
  2. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" >
  3. </script>
  4. <script>
  5. $ (document). Ready (function () {
  6. $ ("P"). Click (function () {
  7. $ (this). Hide (); //$ (this) is within the method click, where $ (this) represents the object that is currently calling the click Method ("P"), which is the object that represents the current object, which is currently called by the method
  8. });
  9. });
  10. </script>
  11. <body>
  12. <p> If you click on me, I will disappear. </p>
  13. <p> Click me and I'll disappear. </p>
  14. <p> also want to click on me Oh. </p>
  15. </body>

If my thoughts are wrong, you are welcome to criticize me.

A word to tell you what jquery $ (this) exactly refers to, how to use

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.