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 Code is as follows:
:
The international team that qualify for the 2012 European Cup "death group" is:
Germany
Denmark
Netherlands
Portugal
1. The first and second place in the group can only be selected.
The Code is as follows:
Var len = $ ("input [name = 'nation']: checked"). length;
If (len = 0 ){
Alert ("select the qualifying National Team! ");
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.
The Code is as follows:
$ ("Input [name = 'nation']: checked"). each (function (){
Alert ("selected national team:" + $ (this). val ());
});
3. Cancel all selected national teams.
The Code is as follows:
$ ("Input [name = 'nation']: checked"). attr ("checked", false );
4. Select two national teams.
The Code is as follows:
$ ("Input [name = 'nation'] [value = 'Germany ']"). attr ("checked", true );
$ ("Input [name = 'nation'] [value = 'holand']"). attr ("checked", true );
5. You are not allowed to select the National Team.
The Code is as follows:
$ ("Input [name = 'nation']"). attr ("disabled", true );
6. Select the National Team.
The Code is as follows:
$ ("Input [name = 'nation']"). attr ("disabled", false );
7. Select the national team with an even or odd number of indexes (the index starts from 0 ).
The Code is as follows:
// Select the national team with an even Index
$ ("Input [name = 'nation']: even"). attr ("checked", true );
// Select the national team with an odd Index
$ ("Input [name = 'nation']: odd"). attr ("checked", true );