How change color of <button onclick >? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How change color of <button onclick >?

I have SOME <button> and want to change their color https://code.sololearn.com/WoMjqavLSdr8/?ref=app

10th Jul 2019, 4:28 PM
Anastasiia Kudria
Anastasiia Kudria - avatar
4 Answers
+ 2
Could you describe more? What button do you mean? And which colour do you want to change? https://www.sololearn.com/discuss/1316935/?ref=app
10th Jul 2019, 4:32 PM
Seniru
Seniru - avatar
+ 2
You can do in the onclick attribute: "minus(this)" JS: function minus(obj) { //code obj.style.background = "red"; } (this will change the background permanently) Or, better, with CSS with active: button:active { background: red; } (this will only change it while you are clicking on it)
10th Jul 2019, 4:33 PM
Airree
Airree - avatar
+ 1
Thanks, but something is wrong. It doesn't show this color
10th Jul 2019, 6:48 PM
Anastasiia Kudria
Anastasiia Kudria - avatar
0
هاواريو
11th Jul 2019, 1:08 AM
سام سام
سام سام - avatar