用Enter键提交表单而不提交按钮? [英] Submit form with Enter key without submit button?
本文介绍了用Enter键提交表单而不提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文本输入框中使用Enter键提交表单,而无需添加提交按钮?
我记得过去曾经工作过,但现在我测试了它,除非它里面有提交类型的输入字段,否则表单不会被提交。
解决方案
$(input).presspress(function(event){
if(event.which == 13){
event.preventDefault();
$(form)。submit();
}
});
Possible Duplicate:
HTML: Submitting a form by pressing enter without a submit button
How can I submit a form with just the Enter key on a text input field, without having to add a submit button?
I remember this worked in the past, but I tested it now and the form doesn't get submitted unless there's a submit-type input field inside it.
解决方案
$("input").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
$("form").submit();
}
});
这篇关于用Enter键提交表单而不提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文