samedi 20 novembre 2021

jascript random background static page html

i try since 2 hours to change my php code into javascript for static page "html" but i see example and it's not work. i just want in load page change the backgroung image..

could you help me that my code

  window.onload = choosePic;

var myPix = new Array("images/lion.jpg","images/tiger.jpg","images/bear.jpg");

function choosePic() {
     var randomNum = Math.floor(Math.random() * myPix.length);
     document.getElementById("myPicture").src = myPix[randomNum];

in my html

but nothing work

thank for answer




Aucun commentaire:

Enregistrer un commentaire