var walk_the_DOM = function walk(node, func) {
func(node);
node = node.firstChild;
while(node) {
walk(node, func);
node = node.nextSibling
}
}
walk_the_DOM(document.body, (node) => {
console.log(node)
})
var walk_the_DOM = function walk(node, func) {
func(node);
node = node.firstChild;
while(node) {
walk(node, func);
node = node.nextSibling
}
}
walk_the_DOM(document.body, (node) => {
console.log(node)
})
本文标题:递归遍历dom树
本文链接:https://www.haomeiwen.com/subject/jxencrtx.html
网友评论