Domanda

i have the follow code:

<input class="any" type="text" id="myId" name="myName" />

this input is a jquery datepicker.. (http://jqueryui.com/datepicker/)

My JS is as follows:

$('#myId').keypress(function(evt) {
   //codes
});

I tried keypress, keydown and keyup.. all not working in IE..

May be because of the jquery date picker plugin?

I also tried with jquery hotkey plugin (https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js)

But, no success :(

i just want to capture the enter event..

Any help?

Felipe

È stato utile?

Soluzione

If the element doesn't exist on the page on the initial load, then the event may not be bound to the button. Not sure why it works in other browsers though.

Could possibly try this to see if it helps

$(document).on('keypress', '#myId', function() {
 // ....
});

if you're using an older version of jQuery, then you'll need to use .live().

Altri suggerimenti

Solved: http://jsfiddle.net/MJWUw/

IE doesn't recognize a keyevent just with click in this input, but if i navigate until the field with tabspace it works.. i did a workaround to solve this, set the focus manually and it's working right now.

$("#myId").click(function(evt){$(this).focus();});

$('#myId').keyup(function(evt) {
   alert('working!')
});

att

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top