当前位置:网站首页>DOM学习笔记---遍历页面所有元素节点
DOM学习笔记---遍历页面所有元素节点
2022-04-23 07:34:00 【beinlife】
//遍历页面所有元素节点
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");
}
}
//遍历页面所有节点
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://blog.csdn.net/beinlife/article/details/52926895
边栏推荐
- 情境领导者-第七章、解决绩效问题
- [go] common concurrency model [generic version]
- A simple theme of Typecho with beautiful appearance_ Scarfskin source code download
- 单点登录 SSO
- CSV column extract column extraction
- QT compilation qtxlsx Library
- An idea plug-in that doesn't work, but can install X
- 万物互联下如何对设备进行加密
- Talk about the basic but not simple stock data
- 输入/输出系统
猜你喜欢
mysql查询字符串类型的字段使用数字类型查询时问题
clang 如何产生汇编文件
vslam PPT
关于ORB——SLAM运行中关键帧位置越来越近的异常说明
Why are there 1px problems? How?
WordPress爱导航主题 1.1.3 简约大气网站导航源码网址导航源码
LeetCode简单题之统计字符串中的元音子字符串
The simple problem of leetcode is to calculate the numerical sum of strings
The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface
Using qlst excel file
随机推荐
英语课小记(四)
情境领导者-第七章、解决绩效问题
Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
项目上传部分
ApplicationReadyEvent的使用
Using qlst excel file
nn.Module类的讲解
社区团购小程序源码+界面diy+附近团长+供应商+拼团+菜谱+秒杀+预售+配送+直播
【学习】从零开始的音视频开发(9)——NuPlayer
搜一下导航完整程序源码
将实例化对象的方法 给新的对象用
多目视觉SLAM
2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
Comparison of indoor positioning technology
QT reading and writing XML files
岛屿的个数
[learning] audio and video development from scratch (9) -- nuplayer
Positioning of high precision welding manipulator
Qt利用QtXlsx操作excel文件
396. Rotate Function