Trigger a button click with JavaScript on the Enter key in a text box

后端 未结 30 2540
难免孤独
难免孤独 2020-11-21 23:53

I have one text input and one button (see below). How can I use JavaScript to trigger the button\'s click event when the Enter key is pressed ins

30条回答
  •  执笔经年
    2020-11-22 00:41

    This onchange attempt is close, but misbehaves with respect to browser back then forward (on Safari 4.0.5 and Firefox 3.6.3), so ultimately, I wouldn't recommend it.

    
    
    

提交回复
热议问题