How to trigger HTML button when you press Enter in textbox?

后端 未结 12 1276
悲哀的现实
悲哀的现实 2020-12-04 08:13

So the code that I have so far is:

&
12条回答
  •  渐次进展
    2020-12-04 08:51

    There are a js-free solution.

    Set type=submit to the button you'd like to be default and type=button to other buttons. Now in the form below you can hit Enter in any input fields, and the Render button will work (despite the fact it is the second button in the form).

    Example:

        
        
    

    Tested in FF24 and Chrome 35 (formaction is html5 feature, but type is not).

提交回复
热议问题