What does this mean in jquery
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.