标签:16px obj select == let tor 标签 cto child
1 const html=document.querySelector(‘html‘)
2 const htmlChild=html.children;
3 let obj={};
4 function fn(children){
5 for(let i of children){
6 if(obj.hasOwnProperty(i.tagName)){
7 obj[i.tagName]=obj[i.tagName]+1
8 }else{
9 obj[i.tagName]=1;
10 }
11 const child=i.children;
12 if(child.length!==0){
13 fn(child)
14 }
15 }
16 }
17 fn(htmlChild)
18 let tag=Object.entries(obj).sort((a,b)=>{
19 return b[1]-a[1]
20 })
21 console.log(tag)
标签:16px obj select == let tor 标签 cto child
原文地址:https://www.cnblogs.com/ayujun/p/12189720.html