🚧node.traverse()
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
🔰 JS ⟩ browser ⟩ DOM ⟩ types ⟩ Node ⟩ .traverse()
💾 replit: node.traverse()
// depth-first traversal
// 🔸 node.traverse()
Node.prototype.traverse = function(f){
// do something on this node
f(this);
// and on its child nodes
for(let child of this
💈範例:
document.traverse(elem => console.log(elem.nodeName));