I'm having some trouble with a jquery script that is supposed to change my body element's background image when a link is pressed. It works great, the only problem I have is that the page has to have no background set in CSS, and be blank before any link is pressed, wich changes the background. The jquery this uses is really old, tried newer versions but nothing works except this one. Also, I've tried document.body.style.backgroundImage
, still no success, this is maybe because of the old version this script uses. Could you figure out what's wrong here ?
<script language="JavaScript">
<!--
// Copyright 2001 by www.CodeBelly.com
// Please do *not* remove this notice.
var backImage = new Array(); // don't change this
// Enter the image filenames you wish to use.
// Follow the pattern to use more images. The
// number in the brackets [] is the number you
// will use in the function call to pick each
// image.
// Note how backImage[3] = "" -- which would
// set the page to *no* background image.
backImage[0] = "img/1.jpg";
backImage[1] = "img/2.jpg";
backImage[2] = "img/3.jpg";
backImage[3] = "img/4.jpg";
backImage[4] = "img/5.jpg";
backImage[5] = "img/3.jpg";
backImage[6] = "img/4.jpg";
backImage[7] = "img/5.jpg";
backImage[8] = "img/3.jpg";
backImage[9] = "img/1.jpg";
//-----------------------------
function changeBGImage(whichImage){
if (document.body){
document.body.background = backImage[whichImage];
}
}
//-->
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
</script>