Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  76] [ 6]  / answers: 1 / hits: 71937  / 11 Years ago, thu, june 20, 2013, 12:00:00

I need to know how to trigger an enter key on an input. That is, in response to some other event (not a keypress), I need to trigger a keypress of value 13.



(Clarification, I do not want to trigger some event when the enter key is pressed. If I didn't know how to do that, I could find that that's been asked and answered several times on SO. I want the reverse. I am trying to develop a workaround that requires I emulate an 'enter' keypress.)


More From » jquery

 Answers
46

You can do this -



var e = $.Event( keypress, { which: 13 } );
$('#yourInput').trigger(e);



[#77517] Wednesday, June 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sergiobrayanc

Total Points: 162
Total Questions: 97
Total Answers: 94

Location: Lesotho
Member since Wed, Jun 2, 2021
3 Years ago
sergiobrayanc questions
;