I have tried several tutorials online and no one seems to be working properly. I just try to do this:
I have 9 different .jpg images that I need to randomly display on the page load - to be the background. Should it be pretty simple?
Thanks,
EDIT (Sorry, forgot to attach the code - find on the Internet):
$(document).ready(function(){ bgImageTotal=9; randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1; imgPath=('../img/bg/'+randomNumber+'.jpg'); $('body').css('background-image', ('url("'+imgPath+'")')); });
source share