This keyword problem
This keyword problem
Hi all,
I can be considered very newbie to js and jquery land. My question is related this keyword and function binding. I want to bind my sampleMethod function to anchor however I want to still use properties of in sampleMethod. In case at below this function is referring anchor element. How can I do what I want?
- var vanillaFunction = function(){
console.log(this);
x = 1;
this.sampleMethod = function(){
console.log(this);
}
$('#init_forward').bind('click', this.sampleMethod);
}
$(document).ready( function(){
new vanillaFunction();
});
Thanks