“this”,“$ this”和“$(this)”之间有什么区别? [英] What is the difference between “this”, “$this” and “$(this)”?
本文介绍了“this”,“$ this”和“$(this)”之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这三种形式有什么区别:
What is the difference between these three forms:
this
$this
$(this)
推荐答案
典型的用法你通常会看到这样的( $ this
用法可能会有所不同):
In typical usage you'll usually see them like this (the $this
usage may vary):
-
this
- 指你当前处理的处理程序中的DOM元素,但这可能是完全在其他情况下的另一个对象,但它始终是上下文。 -
$ this
- 通常由创建var $ this = $(this)
a缓存版本的jQuery包装版本以提高效率(或链接$(this)
以在许多情况下获得相同的效果)。 -
$(this)
- 该元素的jQuery包装版本,因此您可以访问所有方法(特别是$。fn
)。
this
- Refers to the DOM element in the handler you're currently on, but this may be another object entirely in other situations, but it's always the context.$this
- Usually created byvar $this = $(this)
a cached version of the jQuery wrapped version for efficiency (or chain off$(this)
to get the same in many cases).$(this)
- The jQuery wrapped version of the element, so you have access to all its methods (the ones in$.fn
specifically).
这篇关于“this”,“$ this”和“$(this)”之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文