JavaScript “this” references wrong object [duplicate]
问题 This question already has an answer here: How to access the correct `this` inside a callback? 10 answers Well, this doesn't really refer to the wrong object, but I do not know how to refer to the correct one. function someObj() { this.someMethod1 = function() { var elementBtn = document.getElementById('myBtn'); elementBtn.onclick = function() { this.someMethod2(); //I want this.someMethod2() to be called //...but it tries to call elementBtn.someMethod2() i believe. }; }; this.someMethod2 =