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

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

    <button type="button" onclick="return myFunc1()">Button 1</button>
    <input type="submit" name="go" value="Submit"/>
    
    0 讨论(0)
提交回复
热议问题