欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

JS.GetAllChild(element,deep,condition)使用介绍_javascript技巧

程序员文章站 2022-05-12 21:50:29
...
复制代码 代码如下:

window.GetAllChild = function (element, deep, condition) {
if (!!!deep) { deep = 1; }
if (!!!condition || condition == '') { condition = '1==1'; }
deep--;
if (!!!element || !!!element.childNodes || element.childNodes.length var result = new Array();
for (var i = 0; i if (element.style && (element.style.visibility == 'hidden' || element.style.display == 'none')) {
continue;
}
var child = element.childNodes[i];
if (eval(condition)) {
result.push(child);
}
if (deep > 0) {
result = result.concat(GetAllChild(child, deep, condition));
}
}
return result;
}
相关标签: GetAllChild