Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
$(function() {
  var body = $('body');
  var backgrounds = [
    '//placehold.it/800x600/cf5&text=1',
    '//placehold.it/800x600/f1f&text=2',
    '//placehold.it/800x600/333&text=3',
    '//placehold.it/800x600/0f0&text=4',
    '//placehold.it/800x600/70f&text=5'
  ];
  var current = 0;
  
  // Preload all images
  for(var i=0; i<backgrounds.length; i++){
    var img = new Image();
    img.src= backgrounds[i];
  }
  
  function nextBackground() {
    body.css(
      "background-image",
      "url("+backgrounds[++current % backgrounds.length]+")"
    );
    setTimeout(nextBackground, 5000);
  }
  setTimeout(nextBackground, 5000);
  body.css("background-image", "url("+backgrounds[0]+")");
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
roXonpro
0viewers