所以我有这样的代码:jQuery访问父对象属性?
function theObject(){
this.someelement = $("#someelement");
this.someotherelement = $("someotherelement");
this.someelement.fadeOut(500, function(){
this.someotherelement.attr("title", "something");
this.someelement.fadeIn(500);
});
}
出于某种原因this.someotherelement
是不确定的。我猜,因为它被包裹在function(){}
?
这是元素的ID?您缺少#号。 – Adam 2010-07-22 17:25:42
也发布了一些相关的html,所以它会更清晰...... – gillyb 2010-07-22 17:26:32
函数内部,'this'引用this_meelement(实际上是指它的DOM元素)。大多数(每个?)jQuery函数都需要回调函数,'this'是指您调用函数的(DOM)元素。 – 2010-07-22 17:29:45