Making Enter key on an HTML form submit instead of activating button

前端 未结 7 1686
北恋
北恋 2021-02-03 16:33

I have an HTML form with a single submit input, but also various button elements. When the user presses the \'enter\' key, I\'d expect it to actually s

7条回答
  •  耶瑟儿~
    2021-02-03 17:24

    You don't need JavaScript to choose your default submit button or input. You just need to mark it up with type="submit", and the other buttons mark them with type="button". In your example:

    
    
    

提交回复
热议问题