+ 1

How to change text color?

How to make sure that when you click on different buttons, the color of the text changes differently? And if possible, can this be done as an example? Example: function RedBg() {document.bgColor = 'red';}

6th Jun 2020, 1:51 PM
Mr_Ghost
Mr_Ghost - avatar
4 Respostas
+ 2
For example: <h1>My Text Color</h1> <button onclick="body.style.color = 'red'">Click to red!</button> <button onclick="body.style.color = ''">Click to default!</button>
6th Jun 2020, 2:35 PM
JaScript
JaScript - avatar
+ 1
Look how my code works, I need such a result, only with text.
6th Jun 2020, 2:57 PM
Mr_Ghost
Mr_Ghost - avatar
+ 1
Yes, thank you very much!
6th Jun 2020, 3:50 PM
Mr_Ghost
Mr_Ghost - avatar
0
Another solution will be as follows: function GreenBg() {document.querySelector("body").style.color = 'green';}
6th Jun 2020, 3:29 PM
JaScript
JaScript - avatar