使用jQuery提交后禁用按钮 [英] Disable button after submit with jQuery
问题描述
我知道有很多问题,但我尝试了几种解决方案,没有任何效果。
I know there are a lot of questions about it, but I tried several solutions, and nothing works.
在我的django应用程序中,我有一个表单: p>
In my django app I have a form:
<form method='post'>
<button type='submit'>Send</button>
</form>
一旦用户提交表单,我不会禁用该按钮。使用其他问题,我尝试了几件事情,例如:
I wan't to disable the button once the user has submitted the form. Using other questions, I tried several things, like:
<button type='submit' onclick="this.disabled=true">Send</button>
当我点击,该按钮被禁用...但表单未提交。对于每次尝试,我都有同样的问题:按钮被禁用或表单被提交。我找不到如何做这两个...
When I click, the button is disabled... but the form is not submitted. And for each try I had the same issue: either the button is disabled or the form is submitted. I can't find how to do both...
我正在使用Chrome。任何想法为什么我有这个问题?谢谢你的帮助。
I'm using Chrome. Any idea on why I have this problem? Thank you for your help.
推荐答案
尝试这样:
$('form').submit(function() {
$(this).find("button[type='submit']").prop('disabled',true);
});
这篇关于使用jQuery提交后禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!