先获得你选中的节点,再循环它的children,也就是子节点。
function checkAll(layout) {
var el = document.getElementById(layout).getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if (el[i].type == "checkbox")
{ el[i].checked = true; }
}
}
function clearAll(layout) {
var el = document.getElementById(layout).getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if (el[i].type == "checkbox")
{ el[i].checked = false; }
}
}
function checknode(layout, checkboxname) {
document.getElementById(checkboxname).checked = true;
var el = document.getElementById(layout).getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if ((el[i].type == "checkbox") && (el[i].checked == false)) {
document.getElementById(checkboxname).checked = false;
}
}
}