在我们的组织中,我们仍在使用 IE8 标准。在我们的一个基于 Web 的应用程序中,我们注意到无法通过 Enter
键提交表单。在网上搜索后,我偶然发现了这个答案:https://stackoverflow.com/a/4629047/731052
虽然 jQuery 解决方案确实有效,但我们的用户在按下 Enter
键时仍然会听到“叮”声。有没有办法防止这种情况发生?当我访问 Google 之类的网站时,按 Enter 键时不会听到任何“ clang ”。谢谢!
最佳答案
用这个
if (e.which == '13') {
e.preventDefault();
//then put your code
}
假设您使用的是您有链接的问题中的代码
jQuery.fn.handle_enter_keypress = function() {
if ($.browser.msie){
$(this).find('input').keypress(function(e){
// If the key pressed was enter
if (e.which == '13') {
$(this).closest('form')
.find('button[type=submit],input[type=submit]')
.filter(':first').click();
}
});
}
}
关于jquery - 点击 "enter"按钮不会在 IE8 中提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12609987/