+ 1

[Solved] How to change a single div items color?

It doesnt work. Html: <div class="grid-item" id="1" onclick="Click(this.id)"></div> <div class="grid-item" id="2" onclick="Click(this.id)"></div> Javascript: function Click(id){ var col=document.getElementById(id); col.style.color="red"; } CSS: .grid-container { display: grid; grid-template-columns: 50 50 50 50 50 50 50 50 50 50; background-color: #2196F3; padding: 10px; margin: auto; width: 50%; } .grid-item { background-color: rgba(255, 255, 255, 0.8); border: 1px solid rgba(0, 0, 0, 0.8); padding: 20px; font-size: 30px; text-align: center; }

12th Dec 2018, 9:05 AM
Hampus Mathiesen
Hampus Mathiesen - avatar
1 Odpowiedź
12th Dec 2018, 9:23 AM
Calviղ
Calviղ - avatar