$(this)如何在jQuery中工作 [英] How does $(this) work in jQuery
问题描述
jQuery标记 $(this)
如何正确工作?我知道如何使用它,但jQuery如何知道哪个元素是活动的?什么是获取当前项目的原始Javascript标记,还是只有jQuery?
是一个简单的javascript(DOM)对象,
$(this)
会将对象转换成jQuery对象。 p>
jQuery不需要'知道'这个
是什么,它不会以特殊的方式对待它,在$
$ p $ var myHeaderDiv =报头');
$ myHeaderDiv = $(myheaderDiv); //只是一个变量转换成jQuery对象,就像这样。
How does the jQuery tag $(this)
exactly work? I know how to use it, but how does jQuery know which element is 'active'? And what is the original Javascript tag for getting the current item, or is it jQuery only?
The this
is a simple javascript (DOM) object,
$(this)
will turn the object into a jQuery object.
jQuery doesn't need to 'know' what this
is, it doesn't treat this in a special way, no other than myHeaderDiv
in
var myHeaderDiv = document.getElementById('header');
$myHeaderDiv = $(myheaderDiv); //just a variable transformed into jQuery object, as with this.
这篇关于$(this)如何在jQuery中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!