How do you change the text value of a button in jQuery? Currently, my button has 'Add' as its text value, and upon being clicked I want it to change to 'Save'. I have tried this method below, but so far without success:
$("#btnAddProfile").attr('value', 'Save');
For buttons created with .Button() in jQuery........
Whilst the other answers will change the text they will mess up the styling of the button, it turns out that when a jQuery button is rendered the text of the button is nested within a span e.g.
If you remove the span and replace it with text (as in the other examples) - you'll loose the span and associated formatting.
So you actually need to change the text within the SPAN tag and NOT the BUTTON!
or (if like me it's being done on a click event)
Have you gave your button a class instead of an id? try the following code
To change the text in of a button simply execute the following line of jQuery for
<input type='button' value='XYZ' id='btnAddProfile'>
use
while for
<button id='btnAddProfile'>XYZ</button>
use this
$("#btnAddProfile").html('Save');
Use
.val()
Here's a link to JSfiddle