Submitting a form by pressing enter without a submit button

前端 未结 20 1553
你的背包
你的背包 2020-11-22 06:46

Well I am trying to submit a form by pressing enter but not displaying a submit button. I don\'t want to get into JavaScript if possible since I want everything to work on a

20条回答
  •  渐次进展
    2020-11-22 07:18

    The most elegant way of doing this is to keep the submit-button, but set it's border, padding and font-size to 0.

    This will make the button dimensions 0x0.

    
    

    You can try this yourself, and by setting an outline to the element you will see a dot, which is the outside border "surrounding" the 0x0 px element.

    No need for visibility:hidden, but if it makes you sleep at night, you can throw that in the mix as well.

    JS Fiddle

提交回复
热议问题