如果选中了它下面的复选框,我有这段代码将检查顶级复选框。我还想做的
是取消选中顶级复选框,如果它下面没有选中复选框。我该如何修改这个?
if(this.parentElement == pg.thePart) {
var terminate = false;
var counter = 0;
if(n.className == "myClass") {
z = n.nextSibling;
while(z.id == "row" && z.className != "myClass" && !terminate) {
z.all[0].checked = 0;
z.style.backgroundColor = z.className == "w" ? "ffffff" : "ffffcc";
counter++;
if(counter > 1000) terminate = true;
z = z.nextSibling;
}
} else {
z = n;
while (z.className != "myClass" && !terminate) {
z = z.previousSibling;
counter++;
if(counter > 1000) terminate = true;
}
if(counter > 0 && counter <= 1000) {
z.all[0].checked = 1;
z.style.backgroundColor = "bad3fc";
}
}
}