Skip to content

Instantly share code, notes, and snippets.

@ir3ne
Last active December 29, 2017 18:57
Show Gist options
  • Save ir3ne/dec91b31e9e723cd46d51419f48bcd5b to your computer and use it in GitHub Desktop.
Save ir3ne/dec91b31e9e723cd46d51419f48bcd5b to your computer and use it in GitHub Desktop.
JS Change body background color
const body = document.body;
const colors = ["#820263", "#D90368", "#86CB92", "#2E294E", "#FFD400", "#F46036"];
let i = 0;
function change() {
body.style.backgroundColor = colors[i];
i++;
if(i > colors.length - 1) {
i = 0;
}
}
setInterval(change, 3000);
body {
transition: background-color 2s cubic-bezier(1, 1, 1, 1);
transition-delay: 0s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment