Skip to content

Instantly share code, notes, and snippets.

@benwells
Created March 11, 2014 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benwells/9489658 to your computer and use it in GitHub Desktop.
Save benwells/9489658 to your computer and use it in GitHub Desktop.
Setting a background image at random.
/**
* choose a random background image on
* page load from a number of sequentially
* numbered image files
*/
var numImages = 4;
var index = Math.floor(Math.random() * numImages);
$('div.application-header').css({'background': 'url(https://www.gdg.do/images/banner_imgs/' + index + '.jpg)');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment