views:

85

answers:

2

Hello, I have a few inputTextBoxes and I'm using document.activeElement to handle value changes of those inputboxes called by "change()" function of inputBox element.

the problem is when I change the value of one of the inputboxes and then click in another inputbox... the function will get the document.activeElement of the new inputbox and will not work... how to make the function "know" that the one that changed was the previous one?

+2  A: 

In an element's change() handler, the keyword this will refer to the element which was just changed.

$('#foo').change(function() {
    alert(this.id);  // "foo"
});
nickf
I don't understand =/
Fernando SBS
the problem is that when I change focus to another object the delay in the function will make it think that "this" refer to the actually focused object and not the one which I changed.
Fernando SBS
A: 

actually it worked!!

I changed from:

editBoxAtual = document.activeElement;

to

editBoxAtual = this;

it worked incredible well! thanks

Fernando SBS