function test() {
this.str = "hello";
this.sayHello = function() {
document.write(this.str);
}
this.init = function() {
document.onkeydown = this.sayHello;
}
}
var testing = new test();
testing.init();
上記のコードは、onkeydownイベントで "hello"を出力する必要があります。 しかし、私は "未定義"となります。これをどのように機能させることができますか?イベントでオブジェクト変数を取得する
正確には、私が探していたものです。どうもありがとうございました! –