I'm trying to call a blur function on a variable assigned to a jquery object (an input field). How do I call the function on the variable?
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");
});
}
}
I have also tried -
$(this.day).blur
$(this).day.blur
someObject.day.blur
$(day, this).blur
Any help would be appreciated! thanks