文章内容

2021/5/18 10:35:08,作 者: 黄兵

“this”, “$this” 和 “$(this)”有什么区别

this: 引用您当前使用的处理程序中的DOM元素,但这在其他情况下可能完全是另一个对象,但这始终是上下文。

$this: 通常是由var $this = $(this)jQuery包装版本的缓存版本创建的,以提高效率(或者$(this)在许多情况下,也可以通过连锁来获得相同的效果)。

$(this): 元素的jQuery包装版本,因此您可以访问其所有方法(特别是其中的$.fn方法)。


参考资料:

1、What is the difference between “this”, “$this” and “$(this)”?

分享到:

发表评论

评论列表