I used element.children to iterate through element nodes and childNodes for text node. How can I iterate both text node and element node?
let children = this.element.children;
for (let i = 0; i < children.length; i++) {
// do something with children[i] element
}
let childrenNodes = this.element.childNodes;
for (let i = 0; i < childrenNodes.length; i++) {
if (childrenNodes[i].nodeName == "#text") {
// do something with childrenNodes[i] text node
}
}
Can I access to an element with childNodes?