var p = document.getElementById(e),
nodes = p.querySelectorAll('span');
for (var i=0; i<nodes.length; i++) {
node = nodes[i];
node.innerHTML = ' ';
}
If I make after console.log(p) and console.log(nodes), i see that the changes impacted nodes, but not p. Why and how to apply to p?
If i make nodes = p.childNodes;
all works fine.
So, the main question, why it works with childNodes
and doesn't work with querySelectorAll
?
UPDATED
Finally, adding something like below can solve the issue:
for (var k=0; k<childNodes.length; k++) {
for (var j=0; j<nodes.length; j++) {
if (childNodes[k].id === nodes[j].id) {
p.replaceChild(nodes[j],childNodes[k]);
}
}
}
Where nodes = querySelectorAll
and childNodes = p.childNodes
;