I have a main div containing n * n divs which have either a black background or a white one.
I want them to change their BGcolor by clicking on the main div.
Here's my code (that doesn't work obviously).
function invert(){
var divs = document.getsElementsByTagName("div");
for(i=0; i<divs.length; i++){
if(divs[i].style.backgroundColor=="black")
{
divs[i].style.backgroundColor="white";
}
else if (divs[i].style.backgroundColor=="white")
{
divs[i].style.backgroundColor="black";
}
}
}