【问题标题】:How to disable a button but still allow form submission in Chrome?如何禁用按钮但仍允许在 Chrome 中提交表单?
【发布时间】:2017-10-25 13:42:47
【问题描述】:

我们需要在点击后禁用按钮,以防止再次被点击。

$('#btnSubmit').on('click',
    function(e) {
        $(this).attr('disabled', true);
    });

它在 Microsoft Edge 中运行良好。但是在 Chrome 中,该按钮被禁用,并且永远不会提交表单。当我们弄乱按钮时,Chrome似乎有一个隐含的event.preventDefault()

我们怎样才能在不阻止提交表单的情况下禁用按钮?

【问题讨论】:

标签: jquery forms google-chrome


【解决方案1】:

您需要在表单提交后禁用按钮,而不是单击按钮。根据您的设置,类似这样的内容...

$('#form').on('submit',
    function(e) {
        $(#btnSubmit).attr('disabled', true);
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-24
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    • 2021-01-10
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    相关资源
    最近更新 更多