jquery在表单提交时禁用提交按钮 [英] jquery disable submit button on form submission

查看:107
本文介绍了jquery在表单提交时禁用提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  $('form ').submit(function(){
$('input [type = submit]',this).attr('disabled','disabled');
});

是否有更好的编码方式?

解决方案

您的代码正在更改表单的提交操作。

试试这个:

  $('input [type = submit]')。click(function(){
$(this).attr('disabled','disabled');
$(this).parents ('form')。submit()
})


For whatever reason, though this code does refresh the page, no fields get posted...

$('form').submit(function(){
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

Is there a better way of coding this?

解决方案

Your code is changing the submit action of the form. Instead of submitting, it changes the button attribute.

Try this:

$('input[type=submit]').click(function() {
    $(this).attr('disabled', 'disabled');
    $(this).parents('form').submit()
})

这篇关于jquery在表单提交时禁用提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆