I have onkeypress
event and I want to manipulate element this
. I also have if
statement in the event function. The problem is that the keyword this
is different inside the if
statement block. Is it normal to be like this. What explanation do you have?
example:
$(o).find('input[name=numeric]').keypress(
function (e) {
var a = this; // the real object element which activate the trigger
if (e.keyCode == 13) {
var b = this; //here "this" is different object
}
else
window.ncb.helper.validator.numeric(e);
}
);