I am new to javascript and I have an assignment to create seven circles which should change colour on a mouse click. The first circle is changing colour but the other six just r
In the onclick function pass the element itself using this keyword. It works in this case but remember it is wrong to give same id to more than 1 element. It should be unique.
var circle = document.getElementById("circle1");
colors = ['orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
function a(e)
{
color = colors.shift();
colors.push(color);
e.style.fill = color;
}
Rainbow Colours