<head></head>

<body class="standard">
  
  <button>Toggle Background Color</button>
  
</body>
.standard {
  background-color:#eee;
}

.toggle {
  background-color:#4d4d4d;
}
var button = document.querySelector("button");
var background = document.querySelector("body");

button.addEventListener("click", changeBackgroundColor);

function changeBackgroundColor() {
  background.classList.toggle("toggle");
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.