最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - javascript - document.activeElement - Stack Overflow

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论