[Javascript] Deep Search nested tag element in DOM tree
生活随笔
收集整理的這篇文章主要介紹了
[Javascript] Deep Search nested tag element in DOM tree
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// For example you want to search for nested ul and ol in a DOM tree branch
// Give example <ol> <li> <ol> <li></li> </ol> </li> </ol> should retrun 2
// Give example <ol> <li> <ol> <li></li> </ol> </li> </ol> should retrun 2
function solution( tags = ['ul', 'ol']) {
const [uls, ols] = tags.map(tag => Array.from($(`${tag}`)));
const [logUl, logOl] = tags.map(tag => new Logger(`${tag}`));
deepSearch(uls, 'ul', logUl);
deepSearch(ols, 'ol', logOl);
return logUl.count + logOl.count;
}
?
總結
以上是生活随笔為你收集整理的[Javascript] Deep Search nested tag element in DOM tree的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 量子计算机,开启中国速度
- 下一篇: 利用反射机制获取未知类型的枚举的信息