<script type="text/javascript"> var fond = new Array("url(img/soldat1.jpg)", "url(img/soldat2.jpg)", "url(img/soldat3.jpg)"); window.onload = function (){ if (document.getElementById('centrale').style.backgroundImage == "url(img/soldat1.jpg)") { var rand = Math.floor(Math.random() * fond.length); document.getElementById('centrale').style.backgroundImage=fond[rand]; } </script>
<script type="text/javascript"> var fond = new Array("url(img/soldat1.jpg)", "url(img/soldat2.jpg)", "url(img/soldat3.jpg)"); window.onload = function (){ var rand = Math.floor(Math.random() * fond.length); document.getElementById('centrale').style.backgroundImage=fond[rand]; } </script>/code
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionwindow.onload = function (){ var rand = Math.floor(Math.random() * fond.length); document.getElementById('centrale').className=fond[rand]; }
tu cree dans le css plusieur class avec un background different il ne restera plus qu'a attribuer une des class grace au script