How to change a text button in jQuery
For buttons created with .Button() in jQuery........
Simply put, you can also try something like this:
- Button Name
And in your jquery code usually wrapped in Javascript, you can do something like:
- $("#mytxt").text("New Button Value");
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!
- $("#thebutton span").text("My NEW Text");
or (if like me it's being done on a click event)
- $("span", this).text("My NEW Text");
Articoli simili
- How to make the background image of a button disappear when we click it, and make it appear on another button when we click it in Visual Studio
- Why does Android button shape changes but not color after applying background drawable (Android, button, Android drawable, development)?
- Is there any way in c to change the value of a global variable through a function without passing it to the function?
- How to make submit button without form