我刚刚发现,只包含一个输入(不是隐藏的)的表单会在按Enter时自动提交。
但当按enter键时,包含至少两个输入(未隐藏)的表单将不会提交。
(所有脚本中都没有submit/button/inputtype=submit )
看看这个jsfidle。对此行为有没有一个解释/标准?
<form id="form1" method="POST">
<p>Does submit:</p>
<input type="text" placeholder="focus and press enter"/>
</form>
<form id="form2" method="POST">
<p>Does <strong>not</strong> submit:</p>
<input type="text" placeholder="does not submit"/>
<input type="text" placeholder=""/>
</form>发布于 2014-11-24 16:03:17
添加以下应在IE中工作的内容。
$(document).ready(function() {
$('input,select').keypress(function(event) { return event.keyCode != 13; });
});
https://stackoverflow.com/questions/17797025
复制相似问题