Created
August 6, 2014 15:57
-
-
Save livercake/c4bed0f8fa94d9dd488a to your computer and use it in GitHub Desktop.
javascript image randomizer (with array)
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 bgArray = ['bg1.jpg', 'bg2.jpg', 'bg3.jpg', 'bg4.jpg', 'bg5.jpg']; | |
var bg = bgArray[Math.floor(Math.random() * bgArray.length)]; | |
var path = 'http://localhost/img/'; | |
$('#welcome').css('background-image', 'url('+path+bg+')'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment