0
可能重复:
“this” keyword in event methods when using JavaScript prototype object从另一个成员函数调用成员函数在JavaScript
我创建了一个名为“MyClass的”在JavaScript类和约束onclick事件到按钮上这一页。当onclick事件触发时,我想调用另一个成员函数,但它给了我一个未定义的错误。请帮忙。
//MyClass constructor
MyClass = function() {
//Find search button
this.ctrlSearchButton = $("#btnSearch");
//Attach onclick event to search button
this.ctrlSearchButton.click(this.onSearchButtonClick);
};
MyClass.prototype.onSearchButtonClick = function() {
DoSearch();// ERROR : Object Expected
};
MyClass.prototype.DoSearch = function() {
alert("search called");
};
帮我:http://stackoverflow.com/a/4947449/470749 – Ryan