appendChild in for loop only adds 1 child

You are appending the same element over and over. You need to call document.createElement each time you wish to have a new element.

EDIT: If the element setup is really complicated and potentially includes children then you can also use Node.cloneNode

Leave a Comment