JS.GetAllChild(element,deep,condition)使用介绍
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:window.GetAllChild=function(element,deep,condition){if(!!!dee...
复制代码 代码如下:
window.GetAllChild = function (element, deep, condition) {
if (!!!deep) { deep = 1; }
if (!!!condition || condition == '') { condition = '1==1'; }
deep--;
if (!!!element || !!!element.childNodes || element.childNodes.length <= 0) { return []; }
var result = new Array();
for (var i = 0; i < element.childNodes.length; 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;
}