Last active
December 31, 2015 18:37
-
-
Save johnsiwicki/7b6d1d0a964bfab8c3e4 to your computer and use it in GitHub Desktop.
swap background images on a timeer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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