【发布时间】:2013-11-30 14:06:28
【问题描述】:
如何从事件处理程序内部调用 Go 方法?
function Test()
{
this.yo = "YO";
this.Go = function()
{
alert(this.yo);
}
$(".aha").click(function()
{
//Call Go();
});
}
var test = new Test();
【问题讨论】:
-
@TusharGupta 哇,不要把你的编码风格强加给别人的问题。那是完全不恰当的编辑。
-
另一个选项:.click(function(){ this.Go() } .bind(this));我喜欢这样,因为 e.target 将引用“旧 this”,也就是被点击的元素。你也可以只做 .click(this.Go.bind(this));
标签: javascript jquery oop