133
rated 0 times
[
140]
[
7]
/ answers: 1 / hits: 22243
/ 13 Years ago, wed, january 11, 2012, 12:00:00
I've tried several tutorial on the web and none seems to work properly. What I'm trying to do is quite simple I think:
I have 9 different .jpg images that I need to randomly show up on page load - to be background. This should be fairly simple right?
Thanks,
EDIT (Sorry, forgot to attach the code - found in the web):
$(document).ready(function(){
bgImageTotal=9;
randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1;
imgPath=('../img/bg/'+randomNumber+'.jpg');
$('body').css('background-image', ('url('+imgPath+')'));
});
More From » jquery