在jQuery中,$(this)和this有什么不同?为什么它们有时给出相同的结果,而有时表现不同?
发布于 2010-09-10 22:43:14
$(this)用jQuery功能包装了this。
例如,以下代码将失败:
$('.someDiv').onClick(function(){
// this refers to the DOM element so the following line would fail
this.fadeOut(100);
});所以我们将this包装在jQuery中:
$('.someDiv').onClick(function(){
// wrap this in jQuery so we can use jQuery fadeOut
$(this).fadeOut(100);
});https://stackoverflow.com/questions/3685508
复制相似问题