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?

9th Jun 2018, 8:57 PM
Tence Sailor
Tence Sailor - avatar
3 Antworten
+ 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
9th Jun 2018, 9:15 PM
TurtleShell
TurtleShell - avatar
+ 1
Depends how the text options will be selected: randomly, on specific conditions ect or you could change the variable throughout the script
9th Jun 2018, 9:44 PM
TurtleShell
TurtleShell - avatar
0
that works pretty well, but what if i need multiple text options for one of the buttons?
9th Jun 2018, 9:40 PM
Tence Sailor
Tence Sailor - avatar