如何在jQuery中更改按钮的文本值?目前,我的按钮有“添加”作为其文本值,点击后,我希望它改变为“保存”。我尝试过下面这个方法,但到目前为止还没有成功:

$("#btnAddProfile").attr('value', 'Save');

当前回答

$("#btnviewdetails").click(function(){
    if($(this).val()!="hide details"){
        $("#detailedoutput").show();
        $(this).val('hide details');
    }else{
        $("#detailedoutput").hide();
        $(this).val('view more details');
    }

});

其他回答

使用.val ()

这里有一个到jsf的链接

document.getElementById('btnAddProfile').value='Save';

$(“#btnAddProfile”).text(“保存”);

使用JQuery修改按钮文本的正确方法是使用.button()方法:

$( ".selector" ).button( "option", "label", "new text" );

在c#中更改按钮礼仪的名称。

<button type="submit" name="add" id="btnUpdate" class="btn btn-primary" runat="server" onserverclick="btnUpdate_Click">
Add

btnUpdate.**InnerText** = "Update";