How can I Make the background color of the white buttons change color when clicked on any one color and click a button? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I Make the background color of the white buttons change color when clicked on any one color and click a button?

https://code.sololearn.com/WPXKz1IAUcxV/?ref=app

28th Jun 2018, 5:29 PM
B.D
B.D - avatar
3 Answers
+ 4
function changeColor(a) { document.getElementById("cell" ).style.background =a; } First of all Learn difference between class and id, you are using id multiple times which is wrong it will hit only first one and leave the rest. Use class instead.
28th Jun 2018, 5:46 PM
ᴋᵘⁿᵃˡ
ᴋᵘⁿᵃˡ - avatar
29th Jun 2018, 12:54 AM
Calviղ
Calviղ - avatar
+ 1
thanks
29th Jun 2018, 8:07 AM
B.D
B.D - avatar