简体   繁体   English

jQuery:隐藏表单提交按钮但保留功能

[英]jQuery: hide form submit button but keep functionality

How can I hide the form submit button but keep its functionality (typing Return/Enter in submits form)? 如何隐藏表单提交按钮但保留其功能(在提交表单中键入Return / Enter)?

Using .hide() (or display:none via CSS) removes the submit on return functionality. 使用.hide() (或通过CSS display:none )将删除提交返回功能。

Instead of using display: none; 而不是使用display: none; , use visibility: hidden; ,使用visibility: hidden;

I'm not sure why it would be necessary, but you can use this type of CSS: 我不确定为什么有必要,但你可以使用这种类型的CSS:

http://jsfiddle.net/isherwood/58Y76 http://jsfiddle.net/isherwood/58Y76

input[type="submit"], button[type="submit"] {
    position: absolute;
    left: -999em;
}

This puts an element offscreen without scrollbars. 这会在没有滚动条的情况下将元素放在屏幕外。

I used a <button id="tmp"></button> instead of <input type="submit"></input> . 我用<button id="tmp"></button>代替<input type="submit"></input>

And then in CSS: 然后在CSS中:

#tmp{
  display:none
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM