The difference between this and $(this) in Jquery

博客主要介绍了jQuery中的$()、this和$(this)。$()是jQuery选择器,可操作HTML元素组或单个元素;this在JS里指HTML元素;$(this)是选择当前元素的选择器,可通过$(this).xxx操作其属性,还给出了相关参考链接。

$()

$() , It’s jquery selectors.
The selector allows you to manipulate groups of HTML elements or individual elements.

In HTML DOM terminology:
The selector allows you to operate on a DOM element group or a single DOM node.

this

What is “this”?
In many object-oriented programming languages, this (or self) is a keyword which can be used in instance methods to refer to the object on which the currently executing method has been invoked.
In JS, this refers to an element of html. It has various attributes, but these attributes are not all displayed in html.

$(this)

As we know, this and selector. what is “$(this)” ?
( t h i s ) , I t i s a s e l e c t o r f o r s e l e c t i n g t h e c u r r e n t e l e m e n t . S o w e c a n m a n i p u l a t e i t s p r o p e r t i e s b y " (this), It is a selector for selecting the current element. So we can manipulate its properties by " (this),Itisaselectorforselectingthecurrentelement.Sowecanmanipulateitspropertiesby"(this).xxx".

Reference

http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值