当前位置:网站首页>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
边栏推荐
- ansible自動化運維詳解(一)ansible的安裝部署、參數使用、清單管理、配置文件參數及用戶級ansible操作環境構建
- An idea plug-in that doesn't work, but can install X
- word加水印
- Search the complete navigation program source code
- PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)
- How to encrypt devices under the interconnection of all things
- dmp引擎工作总结(2021,光剑)
- The third divisor of leetcode simple question
- 有意思的js 代码
- form表单 post提交 数据量大的问题
猜你喜欢
随机推荐
室内定位技术对比
【深度好文】Flink SQL流批⼀体化技术详解(一)
队列(c语言/链表)
vslam PPT
ASAN 极简原理
form表单 post提交 数据量大的问题
Protobuf简介
Let the earth have less "carbon" and rest on the road
dried food! Point based: differentiable Poisson solver
二维01背包
QFileDialog select multiple files or folders
npm安装yarn
SYS_CONNECT_BY_PATH(column,'char') 结合 start with ... connect by prior
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
excle加水印
记录:js删除数组中某一项或几项的几种方法
Overview of bus structure
作文以记之 ~ 二叉树的前序遍历
How to generate assembly file
JS common array methods









