【发布时间】:2010-11-06 06:41:57
【问题描述】:
var UI$Contract$ddlForm_change = function() {
//'this' is currently the drop down that fires the event
// My question is can I change the context so "this" represents another object?
this = SomeObject;
// then call methods on the new "this"
this.someMethod(someParam);
};
这可能吗?
【问题讨论】:
-
查看这个问题的答案:stackoverflow.com/questions/456967/…
-
是的,或多或少是 stackoverflow.com/questions/456967/… 的副本,接受的答案是使用 call()/apply(),请参阅 developer.mozilla.org/en/Core_JavaScript_1.5_Reference/…
-
这太令人困惑了。所有的答案都说不,你不能这样做。显然,重复问题的答案是的,你可以做到。去图吧。
标签: javascript this dom-events