I am currently working through this tutorial: Getting Started with jQuery(我目前正在研究本教程: jQuery入门)
For the two examples below:(对于以下两个示例:)
$("#orderedlist").find("li").each(function (i) {
$(this).append(" BAM! " + i);
});
$("#reset").click(function () {
$("form").each(function () {
this.reset();
});
});
Notice in the first example, we use $(this)
to append some text inside of each li
element.(注意在第一个示例中,我们使用$(this)
在每个li
元素内附加一些文本。) In the second example we use this
directly when resetting the form.(在第二个示例中,我们在重置表单时直接使用this
。)
$(this)
seems to be used a lot more often than this
.($(this)
似乎比this
经常使用。)
My guess is in the first example, $()
is converting each li
element into a jQuery object which understands the append()
function whereas in the second example reset()
can be called directly on the form.(我的猜测是在第一个示例中, $()
将每个li
元素转换为一个能够理解append()
函数的jQuery对象,而在第二个示例中, reset()
可以直接在表单上调用。)
Basically we need $()
for special jQuery-only functions.(基本上,我们需要$()
用于特殊的仅jQuery函数。)
Is this correct?(这个对吗?)
ask by Kevin Wu translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…