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

前端 未结 7 1672
北恋
北恋 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:18

    I just gave this a whirl in both Chrome and Firefox and IE10.

    As mentioned above - make sure that you have marked up with type = "button", "reset", "submit" etc to ensure that it correctly cascades and chooses the correct button.

    Perhaps also setting all of them to have the same form (ie all as that worked for me)

提交回复
热议问题