gpt4 book ai didi

javascript - 提交表单后的操作

转载 作者:行者123 更新时间:2023-12-03 12:02:32 25 4
gpt4 key购买 nike

提交表单后是否可以更改字段的值?

我有一个表单,其中选择字段被禁用,为了发布表单,我启用了它,但在我希望将其设置回禁用后立即是true。这是我的代码:

    $("Form").submit(function() {
$("#done", this).prop("disabled", false);
});

最佳答案

我现在无法测试它,但请尝试这种方法:

$('Form').submit(function (e) {
e.preventDefault(); // don't submit multiple times
$('Form.select').prop('disabled', true); // Enable the select
this.submit(); // use the native submit method
$('Form.select').prop('disabled', false); // Disable the select
});

让我知道这是如何实现的。

或者

    $('Form').submit(function (e) {
e.preventDefault(); // don't submit multiple times
$('Form.select').prop('disabled', true); // Enable the select
$.post('action.php', $('Form').serialize()); // AJAX submit
$('Form.select').prop('disabled', false); // Disable the select
});

祝你好运!

关于javascript - 提交表单后的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25348484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com