Here is some code:
var class = function(elem,div){
this.elem= elem;
this.div = div;
this.init = function(){
this.div.bind('keyup',this.handler);
}
this.handler= function(event){
//HOW DO I GET "this.elem" ???
//here, this = div
}
this.init();
}
I want to get the variable “elem” from within my “handler” function, but everytime i call this.elem, the “this” is referring to the elem that was bound to the event handler!!.
Well, you could just reference
elem.Or you could declare
var that = this;outside of the the handler and then referencethat.elem.