Skip to content

Instantly share code, notes, and snippets.

@johnsiwicki
Last active December 31, 2015 18:37
Show Gist options
  • Select an option

  • Save johnsiwicki/7b6d1d0a964bfab8c3e4 to your computer and use it in GitHub Desktop.

Select an option

Save johnsiwicki/7b6d1d0a964bfab8c3e4 to your computer and use it in GitHub Desktop.
swap background images on a timeer
var i =0;
var images = ['http://d6449bb3dc657045bfc9-290115cc0d6de62a29c33db202ae565c.r80.cf1.rackcdn.com/1214/mm-luxury-bg-img2-1600x544.jpg',
'http://placehold.it/350x150','http://placehold.it/350x150'];
var image = $('.main-message-wrap');
//Initial Background image setup
image.css('background-image', 'url(image1.png)');
//Change image at regular intervals
setInterval(function(){
image.css('background-image', 'url(' + images [i++] +')');
if(i == images.length)
i = 0;
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment