当前位置:网站首页>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
边栏推荐
- ELK生产实践
- One click cleanup of pycharm and jupyter cache files under the project
- Comparison of indoor positioning technology
- 数据的删除和修改操作(mysql)
- Online app resource download website source code
- Asan minimalism
- 谈谈那些基础但不简单的股票数据
- 通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
- 2022.4.11-4.17 AI行业周刊(第93期):AI行业的困局
- Detailed explanation of ansible automatic operation and maintenance (I) installation and deployment, parameter use, list management, configuration file parameters and user level ansible operating envi
猜你喜欢
Community group purchase applet source code + interface DIY + nearby leader + supplier + group collage + recipe + second kill + pre-sale + distribution + live broadcast
excle加水印
Flink SQL实现流批一体
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
LeetCode简单题之统计字符串中的元音子字符串
2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)
How to read books and papers
项目上传部分
【深度好文】Flink SQL流批⼀体化技术详解(一)
随机推荐
Campus transfer second-hand market source code download
监控智能回放是什么,如何使用智能回放查询录像
QFileDialog select multiple files or folders
The third divisor of leetcode simple question
[effective go Chinese translation] part I
Online yaml to XML tool
英语课小记(四)
How to generate assembly file
Misunderstanding of flush () method of OutputStream class
JS converts tree structure data into one-dimensional array data
Install MySQL for Ubuntu and query the average score
QT reading and writing XML files
Vowel substring in statistical string of leetcode simple problem
Introduction to protobuf
5.6 综合案例-RTU-
数据的删除和修改操作(mysql)
Input / output system
form中enctype属性
耳穴减肥自身感受细节描述0422
作文以记之 ~ 二叉树的前序遍历