Home > Web Front-end > JS Tutorial > What does this mean in jquery

What does this mean in jquery

WBOY
Release: 2022-07-25 15:32:54
Original
7370 people have browsed it

This in jquery means "current object". This represents the current element in html. Use the "$(this)" statement to turn the html element into a jquery object, and then use the jquery method to process the current Object, the syntax is "$(this).jquery method name();".

What does this mean in jquery

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

What does this mean in jquery

this is the dom object. To put it bluntly, it is the tags in html. $(this) is the dom object. The object is changed to a JQuery object, so that the Dom object can be processed using JQuery methods later.

First, let’s take a look at the $() symbol in JQuery. In fact, this symbol is equivalent to JQuery() in JQuery, that is, $(this)=jquery(); that is, this can return a jquery object. Then, when you alert($('#id')); on the web page, an [object Object] will pop up. This object object is also a jquery object.

The example is as follows:

<html>
<head>
<meta charset="utf-8">
<title>123</title>
<script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();//$(this)是在方法click内,此处的$(this)表示的是当前调用click方法的对象$("p"),就是表示当前对象,当前调用该方法的对象
  });
});
</script>
</head>
<body>
<p>如果您点击我,我会消失。</p>
<p>点击我,我会消失。</p>
<p>也要点击我哦。</p>
</body>
</html>
Copy after login

Output result:

What does this mean in jquery

##Related video tutorial recommendation:

jQuery video tutorial

The above is the detailed content of What does this mean in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template