How do I make only one class div element changeable, so that if one is clicked, others can't be? Javascript

I’m trying to make a rating system, so that only one div at a time can be changed, but all of them can still be clicked. const number = document.getElementsByClassName(‘number’); function changeColor(arg) { arg.addEventListener(‘click’, () => { arg.style.backgroundColor = ‘hsl(216, 12%, 54%)’; arg.style.color = ‘white’; }) } for (let i = 0; i < number.length;… Read More How do I make only one class div element changeable, so that if one is clicked, others can't be? Javascript

Why am I only targeting panel4 (not the clicked panel) when adding event listeners via a getElementsByClassName array

The expected result is that when you click on each panel, the panel you clicked on moves, then moves back when you click it again. The result with my current code is that no matter which panel you click it is always panel4 that toggles. The reason these need to be added dynamically to each… Read More Why am I only targeting panel4 (not the clicked panel) when adding event listeners via a getElementsByClassName array