子要素をコピーする

<ul id='list'>
  <li>Item1</li>
  <li>Item2</li>
  <li>Item3</li>
</ul>
<ul id='cloneList'></ul>


<script>
const cloneChildNodes = (parentId, target) => {
  const parent = document.getElementById(parentId);
  const copyElement = document.getElementById(target);
  NodeList.prototype.forEach = Array.prototype.forEach;
  parent.childNodes.forEach((node) => {
    const clone = node.cloneNode(true);
    copyElement.appendChild(clone);
  });
};
cloneChildNodes('list', 'cloneList');
</script>

関連記事