0
Dynamic button text
I want four buttons, btn1, btn2, btn3, btn4 to each display unique JavaScript variables that can be changed. When a button is clicked, it will change its text to a new value. How can I accomplish this?
3 Answers
+ 1
To use variable values simply change the second string in the onclick attribute e.g.
onclick="changeButtonText('bt1', var1)"
https://code.sololearn.com/WM4Jsj1exCWF/?ref=app
+ 1
Depends how the text options will be selected: randomly, on specific conditions ect or you could change the variable throughout the script
0
that works pretty well, but what if i need multiple text options for one of the buttons?