提交后更改提交按钮上的文本 [英] Change text on submit button after submission

查看:125
本文介绍了提交后更改提交按钮上的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交后是否可以更改提交按钮上的文本?示例按钮具有Submit(提交)字样,用户提交表单后,该按钮现在将显示为Done(完成)。如果是这样,它是如何完成的?

Is it possible to change the text on the submit button after submission? Example the button has the word Submit and after the user submits the form, the button will now say Done. If so, how is it done?

谢谢!

Thanks!

推荐答案

如果您使用AJAX处理表单,您可以在 $。ajax 像这样的jQuery方法:

If you're using AJAX to process the form, you could simply have the button text change in the success callback of the $.ajax jQuery method like so:

$.ajax({
    ...
    success: function(data){
        ...
        // If using an <input/> as the submit button
        $('BUTTON_SELECTOR').prop('value', 'Done');

        // If using a <button/> as the submit button
        $('BUTTON_SELECTOR').text('Done');
        ...
    }
    ...
});

我希望这有助于您!

这篇关于提交后更改提交按钮上的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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