vendredi 24 avril 2015

Image link with javascript

I am not into javascript, but I really want randomized pictures on my index page so was wondering if there is anything I could do with my current javascript to add image link to each picture?

< img id = "reklame" / >
  < script >
  function getRandomImage() {
    var images = ['bilder/reklame.jpg', 'bilder/reklame1.jpg', 'bilder/reklame2.jpg', 'bilder/reklame3.jpg'];
    var image = images[Math.floor(Math.random() * images.length)];

    return image;
  }

function displayRandomImage() {
  var htmlImage = document.getElementById("reklame");
  htmlImage.src = getRandomImage();
}
displayRandomImage(); < /script>



Aucun commentaire:

Enregistrer un commentaire