Hello, there are three buttons, click on it, a circle is painted in some color, how can this be done?
I am quite a novice, I started doing it as follows, but then I got up in a stupor. On when you need to refer to this
to color the button on which the event occurred.
But one moment, you need to paint not the button itself, but an absolutely positioned element inside it, i.e. circle;
Here is the code:
var btn = document.querySelectorAll('.button'); var change = document.getElementsByClassName('change-element'); function test(){ for (var index = 0; index<change.length; index++) { change[index].style.backgroundColor="black"; } } for (var i = 0; i<btn.length; i++) { btn[i].addEventListener("click", test); }