开发者

IE7 and IE8 change event not being thrown for text input

I have a form that I auto focus at startup of the page with jquery. I also have change event handlers in place for whenever an input changes.

If I change the value of the first field that was autofocused, and then move to the next field, the change event handler doesn't fire. If I remove the autofocusing, and just focus manually, then change it then move to the next field, the change event does fire.

This only happens on IE. It works fine on firefox and chrome.

Anyone experience this before?

CODE:

$('#firstinput').focus();

$('input').live('change', function (){
  alert("changeevent!");
});

UPDATE: It must be something more complicated than just this, because I tested this by itself and it worked just fine. On the real page i have a validator plugin that is probably interfering somehow. When I used the validator plugin on the test page, it had the same problem.

UPDATE2: I narrowed down the line of code that causes this. Add

$('#firstinput').bind('change', func开发者_StackOverflow社区tion() {});

and IE exhibits the bad behavior.


I tested your code on IE7 and IE8 and works perfectly, maybe there is something else...

What if instead of

$('#firstinput').focus();

you use

$('#firstinput').click();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜