JQuery operates the implementation code of inputtypecheckbox. If you need it, you can refer to it. Here, I suggest you read our previous articles.
: The international team that qualify for the 2012 European Cup "death group" is:
GermanyDenmarkNetherlandsPortugal
1. The first and second place in the group can only be selected.
Var len = $ ("input [name = 'nation']: checked"). length; if (len = 0) {alert ("select the international team to qualify! "); Return false;} else if (len <2) {alert (" select two national teams! "); Return false;} else if (len> 2) {alert (" Only two national teams can be selected! "); Return false;} else {return true ;}
2. Traverse selected national teams.
$ ("Input [name = 'nation']: checked "). each (function () {alert ("selected national team:" + $ (this ). val ());});
3. Cancel all selected national teams.
$("input[name='nation']:checked").attr("checked",false);
4. Select two national teams.
$("input[name='nation'][value='Germany']").attr("checked",true); $("input[name='nation'][value='Holland']").attr("checked",true);
5. You are not allowed to select the National Team.
$("input[name='nation']").attr("disabled",true);
6. Select the National Team.
$("input[name='nation']").attr("disabled",false);
7. Select the national team with an even or odd number of indexes (the index starts from 0 ).
// Select the even-numbered National Team $ ("input [name = 'nation']: even "). attr ("checked", true); // select the country team with an odd index $ ("input [name = 'nation']: odd "). attr ("checked", true );
For more information about jQuery input type = checkbox implementation code, see PHP!