Colors

 Can change a specific area or the entire page background, depending.












<div id="changeMe">
<br><br><br>
<script>
let colorIndex = 0;
function changeColor(divToChange) {
  const toChange = document.getElementById(divToChange);
  const colors = ["LavenderBlush", "Ivory", "Azure", "White"];
  if (colorIndex >= colors.length) {
    colorIndex = 0;
  }
  toChange.style.backgroundColor = colors[colorIndex];
  colorIndex++;
}
</script>
<div style="text-align:right"><button onclick="changeColor('changeMe');">Change Background Color</button></div>
</div>
<!-- modified from https://stackoverflow.com/a/42358165 -->

 

Comments