当前位置:网站首页>DOM learning notes - traverse all element nodes of the page
DOM learning notes - traverse all element nodes of the page
2022-04-23 08:25:00 【beinlife】
// Traverse all element nodes of the page
var blanks=[];
function getChildren(parent){console.log(blanks.join("")+"|_"+(parent.nodeType==1?parent.nodeName:parent.nodeValue));
if(parent.children.length>0){
blanks.push("\t");
for(var i=0,len=parent.children.length;i<len;i++){
getChildren(parent.children[i]);
}
blanks.pop("\t");
}
}
// Traverse all nodes of the page
var blanks=[];
function getChildren(parent){console.log(blanks.join("")+"|_"+(parent.nodeType==1?parent.nodeName:parent.nodeValue));
if(parent.childNodes.length>0){
blanks.push("\t");
for(var i=0,len=parent.childNodes.length;i<len;i++){
getChildren(parent.childNodes[i]);
}
blanks.pop("\t");
}
}
getChildren(document);
版权声明
本文为[beinlife]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230734169043.html
边栏推荐
猜你喜欢

Qt编译QtXlsx库

输入/输出系统

QT reading and writing XML files

谈谈那些基础但不简单的股票数据

Online yaml to XML tool

【深度好文】Flink SQL流批⼀体化技术详解(一)

Listed on the Shenzhen Stock Exchange: the market value is 5.2 billion yuan. Lu is the East and his daughter is American

项目上传部分

Vowel substring in statistical string of leetcode simple problem

clang 如何产生汇编文件
随机推荐
常用正则表达式
Campus transfer second-hand market source code download
单点登录 SSO
分布式消息中间件框架选型-数字化架构设计(7)
QFileDialog select multiple files or folders
Asan minimalism
【深度好文】Flink SQL流批⼀体化技术详解(一)
How to encrypt devices under the interconnection of all things
How to read books and papers
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
freertos学习02-队列 stream buffer message buffer
Common regular expressions
vslam PPT
2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
The simple problem of leetcode is to calculate the numerical sum of strings
RPC procedure
CSV column extract column extraction
[C语言] 文件操作《一》
Notes on English class (4)
LeetCode-199-二叉树的右视图