PHP
5
Вклад в тег
let colors = {
'orange': 'rgb(255, 165, 0)',
'blue': 'rgb(0, 0, 255)'
}, buttons = document.getElementsByClassName('btn'), buttonListener = (e) => {
let currentColor = e.srcElement.innerHTML, circles = document.getElementsByClassName('c');
for(let i = 0; i < circles.length; i += 1) {
let currentCircle = circles[i];
if(!currentCircle.style['background-color'] || currentCircle.style['background-color'] != colors[currentColor]) {
currentCircle.style['background-color'] = colors[currentColor];
break;
} else continue;
}
};
Array.from(buttons, btn => btn.addEventListener('click', buttonListener));