javascript - Jquery document.body.background -


i'm having trouble jquery script supposed change body element's background image when link pressed. works great, problem have page has have no background set in css, , blank before link pressed, wich changes background. jquery uses old, tried newer versions nothing works except one. also, i've tried document.body.style.backgroundimage , still no success, maybe because of old version script uses. figure out what's wrong here ?

  <script language="javascript">     <!--      // copyright 2001 www.codebelly.com     // please *not* remove notice.      var backimage = new array(); // don't change      // enter image filenames wish use.     // follow pattern use more images.      // number in brackets [] number     // use in function call pick each     // image.      // note how backimage[3] = "" --     // set page *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> 

the following code of line should work you:

$('body').css('background-image', 'url(' + backimage[whichimage] + ')'); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -