开发者

jQuery IE7 / IE8: Bind method events order bug?

Here is sample: http://jsfiddle.net/ewzHu/2/

<input id="testing" />

$('#testing').bind('change keydown',function(e){
    $('body').append('<br />'+e.type);
});

Triggers two change events instead of one in IE only when ENTER button is pressed an开发者_如何学God does not triggers keydown.

If i change the order of bindings like that:

$('#testing').bind('keydown change',function(e){
    $('body').append('<br />'+e.type);
});

Everything seems to be ok.

It looks like a bug, but i'm not so experienced.

Thanks ;)


Could be a bug. I tested this in Firefox, Chrome, IE9, IE8, and IE7 and here are the results I got:

  • Firefox Fired: keydown, then a change.
  • Chrome Fired: keydown, then a change.
  • IE9 Fired: one Keydown Only
  • IE7/8 Fired: two changes

Gotta love browser inconsistencies! I try not to rely on things like this being in the same order. Another option is to wrap it, or fix it, to eat the unneeded event, if it's important.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜