title: how to set anchor tag individual item to an array images
body: <p>I added dynamic images display in specific div but I could not set link (a href)for each image individually.Could you help me?
  Here is my script which I used but not working:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
  var i;
  var timerid = 0;
  var images = ["img1.jpg",
              "img2.jpg",
              "img3.jpg","img4.jpg"];
  
  
  var countimages = 0;
  function startTime()
  {
      if(timerid)
      {
          timerid = 0;
      }
      var tDate = new Date();
  
      if(countimages == images.length)
      {
          countimages = 0;
      }
      if(tDate.getSeconds() % 4 == 0)
      {
          document.getElementById("img1").src = images[countimages];
      }
      countimages++;
      timerid = setTimeout("startTime()", 800);
      switch(countimages){
          case images[0]: images[0].setAttribute('href',"dhow-cruise-creek-dubai.html");
          images[0].innerHTML="dhow-cruise-creek-dubai.html";
              document.appendChild(images[0]);
              break;
          case images[1]:  images[1].setAttribute('href',"dhow-cruise-creek-dubai.html");
          images[1].innerHTML="dhow-cruise-creek-dubai.html";
              document.appendChild(images[1]);
              break;
              case images[2]: images[2].setAttribute('href',"dhow-cruise-creek-dubai.html");
          images[2].innerHTML="dhow-cruise-creek-dubai.html";
              document.appendChild(images[2]);
              }
  
  }
  &lt;/script&gt; 
  </code></pre>