Anyone know a simple method to swap the background color of a webpage using JavaScript?
Css approach:
If you want to see continuous colour, use this code:
body{
background-color:black;
animation: image 10s infinite alternate;
animation:image 10s infinite alternate;
animation:image 10s infinite alternate;
}
@keyframes image{
0%{
background-color:blue;
}
25%/{
background-color:red;
}
50%{
background-color:green;
}
75%{
background-color:pink;
}
100%{
background-color:yellow;
}
}
If you want to see it faster or slower, change 10 second to 5 second etc.