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


复制代码 代码如下:

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;
}

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3