2

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 and 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 ;)

1
  • There's not really much of a standard for things like this, though the HTML5 spec may codify some behaviors.
    – Pointy
    Jun 15, 2011 at 11:25

1 Answer 1

1

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.

4
  • Maybe this have been fixed in 1.6.1+? I'll check in a moment.
    – Somebody
    Jun 15, 2011 at 11:21
  • Doesn't look like 1.6.1 changed anything. Same happening on my end. Jun 15, 2011 at 11:26
  • Erm... offtopic. Sheldon? Sheldon Cooper :D
    – Somebody
    Jun 15, 2011 at 11:32
  • /sigh Yeah, my wife thinks that's funny too. :) Jun 15, 2011 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.