Home > front end >  Wrote a whole box and cancel to cancel the whole box code, but in manual selection option automatica
Wrote a whole box and cancel to cancel the whole box code, but in manual selection option automatica

Time:11-05

 & 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>





CodePudding user response:

 
FruitElts [I] onclick ()=function () {


Change

 
FruitElts [I] onclick=function () {

CodePudding user response:


F12 console have tip position error

CodePudding user response:

See the upstairs has solved the answer, carefully check the building code will find lines of 13 to 29 you will find that problem

CodePudding user response:

Problem has been solved for all was too careless
  • Related