The first step, since it is multiple choice and select all, then you need to click the mouse, so I tried to get their id, respectively, and then add them to the click event
// Get the id box full of
var allCheck = document.getElementById ( "allCheck" );
// add a click event allCheck.addEventListener ( "the Click" , the clickHandler);
// get additional selection frame ID for ( var I =. 1; I <. 5; I ++ ) { var Check = document.getElementById ( "Check" + I);
// add click the event the this .addEventListener ( "the click" , clickHandler); }
The second step, to perform this function click event
function the clickHandler (E) {
// Analyzing this box is not full IF ( the this == allCheck) { for ( var I =. 1; I <. 5; I ++ ) { var Check = document.getElementById ( "Check" + I) ; check.checked = allCheck.checked; } } var bool = true; for(var i = 1; i < 5;i++){ var check = document.getElementById("check"+i); if(!check.checked) bool = false; } allCheck.checked =bool; }
effect: