当前位置:网站首页>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
边栏推荐
- 2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
- QT reads all files under the path or files of the specified type (including recursion, judging whether it is empty and creating the path)
- 編譯原理題-帶答案
- Brief description of CPU
- Positioning of high precision welding manipulator
- Find the largest of 3 strings (no more than 20 characters per string).
- Qt读取路径下所有文件或指定类型文件(含递归、判断是否为空、创建路径)
- 【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
- vmware 搭建ES8的常见错误
- 基于TCP/IP协议的网络通信实例——文件传输
猜你喜欢

synchronized 实现原理

总线结构概述

【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel

项目上传部分

LeetCode简单题之统计字符串中的元音子字符串

Using qlst excel file

Idea: export Yapi interface using easyyapi plug-in

Talk about the basic but not simple stock data

One click cleanup of pycharm and jupyter cache files under the project

ASAN 极简原理
随机推荐
ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建
Interesting JS code
常用正则表达式
form中enctype属性
編譯原理題-帶答案
QFileDialog select multiple files or folders
js常用数组方法
The third divisor of leetcode simple question
将实例化对象的方法 给新的对象用
396. Rotate Function
The following program deletes n consecutive words starting from the ith character from the string str
WordPress love navigation theme 1.1.3 simple atmosphere website navigation source code website navigation source code
Rearranging log files for leetcode simple question
QT compilation qtxlsx Library
数据可视化:使用Excel制作雷达图
情境领导者-第七章、解决绩效问题
MySQL数据库中delete、truncate、drop原理详解
利用Js实现一个千分位
分组背包呀
线程的调度(优先级)