Jquery表单提交按钮(chrome问题)

Rob*_*Rob 1 javascript forms jquery

我试图阻止表单提交两次.我是通过捕获提交按钮的单击并在表单提交在后台继续时禁用它来实现的.

这是我正在使用的代码的一个非常基本的例子:

$("button").click(function(){
    $(this).attr("disabled","true").html("Wait here while posted...");
});
Run Code Online (Sandbox Code Playgroud)

工作示例:http: //jsfiddle.net/t93Vw/

这在firefox和IE中完美运行,但在chrome中,表单未提交.为什么这种行为不同,有没有人快速解决?

dfs*_*fsq 5

如果您想提交表格,那么您应该使用onsubmit活动:

$("form").submit(function () {
    $(':submit', this).prop("disabled", true).html("Wait here while posted...");
});
Run Code Online (Sandbox Code Playgroud)

onclick用于点击,表格有一个特殊的提交事件.优点是它将在Enter键提交时正常运行.

演示:http://jsfiddle.net/t93Vw/1/