& lt; ! DOCTYPE html>
<meta charset="utf-8" & gt;
<body>Window. The onl oad=function () {
Var allCheck=document. GetElementById (" FirstCheck ")
Var fruitElts=document. GetElementsByName (" fruit ")
AllCheck. Onclick=function () {
If (allCheck. Checked) {
for(var i=0; iFruitElts [I]. Checked=true
}
} else {
for(var i=0; iFruitElts [I]. Checked=false
}
}
}
Var all=fruitElts. The total length//obtain option box
for(var i=0; iFruitElts [I] onclick ()=function () {
Var checkedCount=0//counter to zero
for(var j=0; j
If (fruitElts [j]. Checked) {
CheckedCount++
}//judgment options dialog state, add a counter to be checked if
}
AllCheck. Checked=(all==checkedCount)//whether total counter and option box are equal, if all equal checked marquee
}
}
}
</script>