I am working on a unique HTML canvas for pixel art, which is created using a table made up of various divs all sharing the "pixel" class. I want to add a clear button that can reset the entire canvas, but changing the background color of each individual div isn't feasible given the number of pixels involved. Can anyone explain why the following code won't work and offer an alternative solution?
function clearCanvas() {
document.getElementsByClassName("pixel").style.backgroundColor = "white";
}
Your input is greatly appreciated!