当前位置:网站首页>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
边栏推荐
猜你喜欢

Online yaml to XML tool

RPC procedure

How to generate assembly file
![[learning] audio and video development from scratch (9) -- nuplayer](/img/62/20b0d80088181fb6ff1fe842500c0a.png)
[learning] audio and video development from scratch (9) -- nuplayer

Flink SQL实现流批一体

Let the earth have less "carbon" and rest on the road

An article understands variable lifting

PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)

vslam PPT

My heart's broken! A woman's circle of friends envied others for paying wages on time and was fired. Even her colleagues who liked her were fired together
随机推荐
CGM优化血糖监测管理——移宇科技亮相四川省国际医学交流促进会
Weekly leetcode - 06 array topics 7 ~ 739 ~ 50 ~ offer 62 ~ 26 ~ 189 ~ 9
欧圣电气深交所上市:市值52亿 陆为东父女为美国籍
2022.4.11-4.17 AI行业周刊(第93期):AI行业的困局
LeetCode简单题之重新排列日志文件
微信小程序 catchtap=“toDetail“ 事件问题
My heart's broken! A woman's circle of friends envied others for paying wages on time and was fired. Even her colleagues who liked her were fired together
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
耳穴减肥自身感受细节描述0422
Install MySQL for Ubuntu and query the average score
An example of network communication based on TCP / IP protocol -- file transmission
396. Rotate Function
Flink SQL实现流批一体
谈谈那些基础但不简单的股票数据
Misunderstanding of flush () method of OutputStream class
There are some problems when using numeric type to query string type fields in MySQL
Qt读写XML文件
LeetCode中等题之旋转函数
Shell script advanced
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel