你如何在HTML中复制图像?

时间:2017-10-31 02:45:59

标签: javascript html

我想连续拍摄5张相同的图像(我可以说div吗?)

<body>
    <div><img src = "picture.jpg";>
    /* code that duplicates or deletes multiple copies of "picture.jpg" */
    </div>
</body>

1 个答案:

答案 0 :(得分:1)

我会做那样的事情:

<div id="list"><img id="item" src = "picture.jpg"></div>

<script type="text/javascript">
  function cloneItem() {
      var item = document.getElementById("item");
      var list = document.getElementById("list");
      var clonedItem = item.cloneNode(true);
      list.appendChild(clonedItem);
  }

  for(var i = 0; i < 5; i++) {
    cloneItem();
  }
</script>