Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  74] [ 5]  / answers: 1 / hits: 62884  / 13 Years ago, wed, may 25, 2011, 12:00:00

I have an input field which is dynamically filled with some AJAX, and once it's filled I would like to have JavaScript to automatically press "Enter" (key event 13) on that input inducing another function, which is hidden to me, to trigger.


Would it be possible with jQuery? I have this code right now, which is not working:


$('#myInputId').focus().trigger({ type : 'keypress', which : 13 });


Do you have any clue on what am I doing wrong?


More From » jquery

 Answers
190

You can create an event object:



$('#myInputId').trigger(jQuery.Event('keypress', { keycode: 13 }));

[#92057] Tuesday, May 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calicinthias

Total Points: 447
Total Questions: 101
Total Answers: 118

Location: Botswana
Member since Sat, Dec 31, 2022
1 Year ago
calicinthias questions
Sun, Jan 2, 22, 00:00, 2 Years ago
Wed, Jan 13, 21, 00:00, 3 Years ago
Mon, Aug 10, 20, 00:00, 4 Years ago
;