2

Hi I don't know how to loop the tag img using javascript or php or whatever? I have around 200 images and the name of image is imaged1.jpg , imaged2.jpg, imaged3.jpg,........,imaged200.jpg something like this....

<DOCTYPE! html>
<html>
<head>
   <script>
      for(var i=1, i < 200,i++)
      {
         var images = document.getElementbyId("photo");
         //////////////////////////////???
      }
   </script>
</head>
<body>
<div>
  <div>

     <img id = "photo" src="imaged i.jpg" />

  </div>
</div>
</body>
</html>
doflamingo
  • 567
  • 5
  • 23
  • check this : http://stackoverflow.com/a/227093/3930193 – Steeve Pitis Oct 11 '16 at 10:03
  • 1
    Possible duplicate of [What is the best JavaScript code to create an img element](http://stackoverflow.com/questions/226847/what-is-the-best-javascript-code-to-create-an-img-element) – Sebastian Sebald Oct 11 '16 at 12:01
  • Please don't give multiple DOM elements the same `id` attribute. It is not supposed to be used like that. Use the `class` attribute or a `data-*` attribute. – Vivek Pradhan Oct 11 '16 at 12:06
  • l'm back. I think It's simple but I forget. just use php loop for($i = 1; $i <= 200; $i++) { echo "
    "; }
    – doflamingo Oct 11 '16 at 14:04

0 Answers0