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);
};
這是可能的嗎? 謝謝, 〜ck在聖地亞哥我可以更改javascript「this」的上下文嗎?
請參閱此問題的答案:http://stackoverflow.com/questions/456967/javascript-how-to-set-this-variable-easily – molf 2009-06-26 20:54:04
yepp,或多或少是http:// stackoverflow的副本。 com/questions/456967/javascript-how-to-set-this-variable-easily 接受的答案是使用call()/ apply(),請參閱https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/apply – VolkerK 2009-06-26 20:56:05