JSFiddle - React, Tailwind, and code Playground

by Ken Z

CSS

html { 
    height: 100% 
}
body {
    background-position: center center;
    background-repeat: no-repeat;
    height: 100%
}

JavaScript

var backImg = -1,
    dbStyle = document.body.style,
    backgnd = [
        'url(http://placekitten.com/350/350)',
        'url(http://placekitten.com/349/349)'
    ]; 

function swapBG() {
    dbStyle.backgroundImage = backgnd[ backImg++ ]
        ? backgnd[ backImg ]
        : backgnd[ backImg = 0 ];
}

swapBG();
setInterval(function(){
   swapBG();
   setTimeout(function(){ 
       swapBG()
   }, 2000 );
}, 23000);