Javascript - document.activeElement

I have several inputTextBoxes, and I use document.activeElement to handle changes to the values ​​of those input boxes that are called by the "change ()" function of the inputBox element.

the problem is that I change the value of one of the input boxes and then select another input field ... the function will receive the document. activeElement of the new input will not work ... how to make the function "do you know that the one that changed was the previous one?"

+3
source share
2 answers

In the item handler, the change()keyword thiswill refer to the item just modified.

$('#foo').change(function() {
    alert(this.id);  // "foo"
});
+3

!

:

editBoxAtual = document.activeElement;

editBoxAtual = this;

!

0

Source: https://habr.com/ru/post/1750031/


All Articles