我試圖調用一個模糊函數分配給一個jQuery對象(輸入字段)的變量。如何在變量上調用函數?Javascript中的對象表示法
var someObject = {
day: $('#dayInputField'), // input text field
init:function(){
console.log("this.day" + this.day); // outputs object
this.validateField();
},
validateField : function(){
//this gets triggered - but I need to reference the variable
$('#dayInputField').blur(function(){
console.log("This gets triggered");
};
// this doesn't get triggered - how do I target the variable?
this.day.blur(function(){
console.log("doesn't work");
});
}
}
我也曾嘗試 -
$(this.day).blur
$(this).day.blur
someObject.day.blur
$(day, this).blur
任何幫助,將不勝感激! 感謝
是您的代碼上或DOM後運行準備好了? – 2010-08-21 12:09:28
這是外面 - 感謝尼克的幫助。 – Matt 2010-08-21 12:24:35