Created
July 25, 2013 14:36
-
-
Save agriboz/6080317 to your computer and use it in GitHub Desktop.
Page load different background http://stackoverflow.com/questions/12115883/onload-javascript-assign-background-image-to-div
This file contains 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
$(window).load(function(){ | |
var images = ['bg1', 'bg2', 'bg3']; | |
var imageRandom = Math.floor( Math.random() * images.length ); | |
var imagesUrl = 'url(../img/' + images[imageRandom] + '.jpg)'; | |
$('body').css('background-image', imagesUrl); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment