有沒有一種方法可以從同一個對象內配置的jquery按鈕單擊調用公共方法?下面我向你展示我已經試過的多種方式從自己的對象javascript調用的公共方法?
var myClass = new MyClass();
function MyClass() {
this.func1 = function() {
alert("Hello World");
}
var me = this;
$("#my-button").click(function(){
//func1(); //dont work (wold like)
//this.func1(); //dont work (would like)
me.func1(); //Work! but is not correct way to do it
myClass.func1(); //Work! but the idea its that recognize itself widthout call public instance
});
}
其他的方法?
_me.func1(); //工作!但不是正確的做法_這是怎麼回事? –
你是什麼意思的「公共方法」? – Phrogz
@ParthThakkar我會問同樣的問題 – fcalderan