childNodes遍历DOM节点树

childNodes遍历DOM节点树
var s = "";
function travel(space,node) {
    if(node.tagName){
        s += space + node.tagName + "
" } var len = node.childNodes.length for (var i=0; i){ travel(space+"--",node.childNodes[i]) } } travel("*", document) document.write(s);

 

转载于:https://www.cnblogs.com/hjbky/p/8418544.html

你可能感兴趣的:(childNodes遍历DOM节点树)