如何使用 jquery 更改按钮的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3402288/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 15:23:34  来源:igfitidea点击:

How to change the value of the Button using jquery

jquery

提问by kumar

I have one more button on the page called Edit when I click on Edit button I need to Change the Add Button value to SAVE...using jquery..

当我单击“编辑”按钮时,页面上还有一个名为“编辑”的按钮,我需要将“添加按钮”值更改为“保存”...使用 jquery..

thanks

谢谢

回答by Nick Craver

You can use .val()to set the value of any input (including a button), like this:

您可以使用.val()来设置任何输入(包括按钮)的值,如下所示:

?$("#badd").val("Save");??????

Give it a try here, or just plain JavaScript:

在这里尝试一下,或者只是简单的 JavaScript:

document.getElementById("badd").value = "Save";

回答by Claudio Redi

$('#edit_btn_id').click(function(){
    $('#badd').val('SAVE');
}