admin管理员组

文章数量:1429120

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?

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?

Share Improve this question edited Jun 15, 2010 at 1:26 Warty 7,3861 gold badge34 silver badges53 bronze badges asked Jun 15, 2010 at 1:20 FernandoSBSFernandoSBS 6555 gold badges12 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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"
});

actually it worked!!

I changed from:

editBoxAtual = document.activeElement;

to

editBoxAtual = this;

it worked incredible well! thanks

本文标签: jqueryjavascriptdocumentactiveElementStack Overflow