Answer the question
In order to leave comments, you need to log in
How to clone nodes in a loop with content replacement in js?
Do not tell me what is my mistake?
There is an array with data that needs to be displayed on the screen. I clone the element, after I add the content to its fields, and only one is displayed.
I assume that the error is in the output, but I do not understand how it is correct?
wraper[wraper.length - 1].parentNode.insertBefore(clon, wraper[wraper.length - 1].nextSibling);
for (var i = 0; i < row.length; i++) {
clon.children[0].innerHTML = row[i].split(';')[0];
clon.children[1].innerHTML = row[i].split(';')[1];
console.log(clon.children[0].innerHTML);
wraper[wraper.length - 1].parentNode.insertBefore(clon, wraper[wraper.length - 1].nextSibling);
}
Answer the question
In order to leave comments, you need to log in
on the fiddle I see return in the loop, it returns from the function immediately on the first iteration of the loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question