我正在阅读http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery,但对这两段代码中this
的使用感到困惑。
$(document).ready(function() {
$("#orderedlist").find("li").each(function(i) {
$(this).append( " BAM! " + i );
});
});
$(document).ready(function() {
// use this to reset several forms at once
$("#reset").click(function() {
$("form").each(function() {
this.reset();
});
});
});
我们何时需要使用$(this)
和this
?它们之间有什么区别?谢谢。
$(this)
,而在另一部分需要this
。 - Blazemonger.each()
函数中,this
指的是实际元素。” - user113716