Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does this mean in jquery

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what this means in jquery. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

This in jquery stands for "current object", this represents the current element in html, uses the "$(this)" statement to turn the html element into a jquery object, and then uses the jquery method to process the current object, and the syntax is "$(this) .jQuery method name ();".

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

This is a dom object, to put it bluntly, the tags in html. $(this) changes the dom object to a JQuery object, so that you can then use the JQuery method to deal with the Dom object.

Let's first look at the symbol $() in JQuery, which is actually equivalent to JQuery () in JQuery, that is, $(this) = jquery (); that is, it returns a jquery object. So, when you alert ($('# id')); in a web page, a [object Object] pops up, the object object, that is, the jquery object.

Examples are as follows:

$(document) .ready (function () {$("p") .click (function () {$(this). Hide (); / / $(this) is within the method click, where the $(this) represents the object $("p") that currently calls the click method, that is, the current object, the object that is currently calling the method};})

If you click on me, I will disappear.

Click on me and I will disappear.

Click on me, too.

Output result:

This is the end of the article on "what does this in jquery mean?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report