如何在jQuery中更改按钮的文本值?目前,我的按钮有“添加”作为其文本值,点击后,我希望它改变为“保存”。我尝试过下面这个方法,但到目前为止还没有成功:
$("#btnAddProfile").attr('value', 'Save');
如何在jQuery中更改按钮的文本值?目前,我的按钮有“添加”作为其文本值,点击后,我希望它改变为“保存”。我尝试过下面这个方法,但到目前为止还没有成功:
$("#btnAddProfile").attr('value', 'Save');
当前回答
你给你的按钮一个类而不是一个id?试试下面的代码
$(".btnSave").attr('value', 'Save');
其他回答
如果你有按钮,这似乎工作:
<button id="button">First caption</button>
$('#button').button();//make it nice
var text="new caption";
$('#button').children().first().html(text);
在c#中更改按钮礼仪的名称。
<button type="submit" name="add" id="btnUpdate" class="btn btn-primary" runat="server" onserverclick="btnUpdate_Click">
Add
btnUpdate.**InnerText** = "Update";
$("#btnAddProfile").html('Save').button('refresh');
完全正确,这对我来说很管用;
$('#btnAddProfile').bind('click',function(){
$(this).attr('value','save');
})
你确定Jquery是可用的,你的代码是在正确的地方?
使用.val ()
这里有一个到jsf的链接